List of usage examples for org.apache.commons.mail Email setFrom
public Email setFrom(final String email) throws EmailException
From source file:com.pronoiahealth.olhie.server.services.MailSendingService.java
/** * Sends a password reset email to the email address provided * //from ww w. j ava 2s. c om * @param toEmail * @param newPwd * @throws Exception */ public void sendPwdResetMailFromApp(String toEmail, String newPwd) throws Exception { Email email = new SimpleEmail(); email.setSmtpPort(Integer.parseInt(smtpPort)); email.setAuthenticator(new DefaultAuthenticator(fromAddress, fromPwd)); email.setDebug(Boolean.parseBoolean(debugEnabled)); email.setHostName(smtpSever); email.setFrom(fromAddress); email.setSubject("Reset Olhie Password"); email.setMsg("You have requested that your password be reset. Your new Olhie password is " + newPwd); email.addTo(toEmail); email.setTLS(Boolean.parseBoolean(tlsEnabled)); email.setSocketTimeout(10000); email.setSocketConnectionTimeout(12000); email.send(); }
From source file:com.pronoiahealth.olhie.server.services.MailSendingService.java
/** * Author Request email that goes to the olhie administrator * // ww w. ja v a 2s . com * @param toEmail * @param userId * @param firstName * @param lastName * @param regId * @throws Exception */ public void sendRequestAuthorMailFromApp(String toEmail, String userId, String firstName, String lastName, String regId) throws Exception { Email email = new SimpleEmail(); email.setSmtpPort(Integer.parseInt(smtpPort)); email.setAuthenticator(new DefaultAuthenticator(fromAddress, fromPwd)); email.setDebug(Boolean.parseBoolean(debugEnabled)); email.setHostName(smtpSever); email.setFrom(fromAddress); email.setSubject("Author Request"); email.setMsg("User Id: " + userId + " Name: " + firstName + " " + lastName + " Registration Id: " + regId); email.addTo(toEmail); email.setTLS(Boolean.parseBoolean(tlsEnabled)); email.setSocketTimeout(10000); email.setSocketConnectionTimeout(12000); email.send(); }
From source file:com.pronoiahealth.olhie.server.services.MailSendingService.java
/** * @param toEmail/* w w w. j a v a 2s. co m*/ * @param userId * @param firstName * @param lastName * @param eventId * @param details * @throws Exception */ public void sendRequestMailForCalendarEventFromApp(String toEmail, String userId, String firstName, String lastName, String eventId, String details) throws Exception { Email email = new SimpleEmail(); email.setSmtpPort(Integer.parseInt(smtpPort)); email.setAuthenticator(new DefaultAuthenticator(fromAddress, fromPwd)); email.setDebug(Boolean.parseBoolean(debugEnabled)); email.setHostName(smtpSever); email.setFrom(fromAddress); email.setSubject("Calendar Event Request"); email.setMsg("User Id: " + userId + " Name: " + firstName + " " + lastName + " Event Id: " + eventId + "\n" + details); email.addTo(toEmail); email.setTLS(Boolean.parseBoolean(tlsEnabled)); email.setSocketTimeout(10000); email.setSocketConnectionTimeout(12000); email.send(); }
From source file:FacultyAdvisement.ImagineBean.java
public String submitRequest() { String emailCourses = ""; for (Course c : currentCourses) { emailCourses += "<li>" + c.getSubject() + " " + c.getNumber() + "</li>"; }//from w ww . jav a 2 s.c om try { Email email = new HtmlEmail(); email.setHostName("smtp.googlemail.com"); email.setSmtpPort(465); email.setAuthenticator(new DefaultAuthenticator("uco.faculty.advisement", "!@#$1234")); email.setSSLOnConnect(true); email.setFrom("uco.faculty.advisement@gmail.com"); email.setSubject("Microsoft Imagine Account"); email.setMsg("<font size=\"3\" style=\"font-family:verdana\"> \n" + "<ul><li>Student Name: " + student.getFirstName() + " " + student.getLastName() + "</li><li>Student Major: " + student.getMajorCode() + "<li>Current Courses: <ol>" + emailCourses + "</ol></li></ul> " + "Student Email if needed for response: " + student.getUsername() + "\n<p align=\"center\">UCO Faculty Advisement</p></font>"); email.addTo("uco.faculty.advisement@gmail.com"); email.send(); } catch (EmailException ex) { Logger.getLogger(VerificationBean.class.getName()).log(Level.SEVERE, null, ex); } return "/customerFolder/imagineConfirm"; }
From source file:ch.fihlon.moodini.business.token.control.TokenService.java
@SneakyThrows private void sendChallenge(@NotNull final String email, @NotNull final Challenge challenge) { final SmtpConfiguration smtp = configuration.getSmtp(); final Email mail = new SimpleEmail(); mail.setHostName(smtp.getHostname()); mail.setSmtpPort(smtp.getPort());//from w w w .j av a2s. c om mail.setAuthenticator(new DefaultAuthenticator(smtp.getUser(), smtp.getPassword())); mail.setSSLOnConnect(smtp.getSsl()); mail.setFrom(smtp.getFrom()); mail.setSubject("Your challenge to login to Moodini"); mail.setMsg(String.format("Your one time challenge, valid for 10 minutes: %s", challenge.getChallenge())); mail.addTo(email); mail.send(); }
From source file:br.com.verificanf.bo.NotaBO.java
public void buscar() { /*Inicio - Pegar Configuraes de email do arquivo*/ try {/*from w ww . j a v a2 s . c o m*/ String local = new File("./email.txt").getCanonicalFile().toString(); File arq = new File(local); boolean existe = arq.exists(); if (existe) { FileReader fr = new FileReader(arq); BufferedReader br = new BufferedReader(fr); while (br.ready()) { String linha = br.readLine(); if (linha.contains("host:")) { hostEmail = linha.replace("host:", "").replace(" ", ""); } if (linha.contains("port:")) { portEmail = linha.replace("port:", "").replace(" ", ""); } if (linha.contains("user:")) { userEmail = linha.replace("user:", "").replace(" ", ""); } if (linha.contains("pass:")) { passEmail = linha.replace("pass:", "").replace(" ", ""); } if (linha.contains("from:")) { fromEmail = linha.replace("from:", "").replace(" ", ""); } if (linha.contains("to:")) { toEmail = linha.replace("to:", "").replace(" ", ""); } } } } catch (FileNotFoundException ex) { Logger.getLogger(NotaBO.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro = ""; for (int i = 0; i < st.length; i++) { erro += st[i].toString() + "\n"; } } catch (IOException ex) { Logger.getLogger(NotaBO.class.getName()).log(Level.SEVERE, null, ex); StackTraceElement st[] = ex.getStackTrace(); String erro2 = ""; for (int i = 0; i < st.length; i++) { erro2 += st[i].toString() + "\n"; } } /*FIM - Pegar Configuraes de email do arquivo*/ NotaDAO notaDAO = new NotaDAO(); try { ultimasAtual = notaDAO.getUltimaNotaMesAtual(); ultimasAnterior = notaDAO.getUltimaNotaMesAnterior(); naoEncontradas = new ArrayList<>(); for (Nota notaAnterior : ultimasAnterior) { for (Nota notaAtual : ultimasAtual) { if (notaAnterior.getLoja() == notaAtual.getLoja()) { //System.out.println("Anterior Loja: "+notaAnterior.getLoja()+" Nota: "+notaAnterior.getNumero()); //System.out.println("Atual Loja: "+notaAtual.getLoja()+" Nota: "+notaAtual.getNumero()); Integer numero = 0; for (Integer i = notaAnterior.getNumero(); i <= notaAtual.getNumero(); i++) { numero = i; Nota notacorrente = new Nota(); notacorrente.setLoja(notaAnterior.getLoja()); notacorrente.setNumero(numero); notacorrente.setSerie(notaAnterior.getSerie()); //System.out.println("Corrente Loja: "+notacorrente.getLoja()+" Nota: "+notacorrente.getNumero()); if (!notaDAO.notaIsValida(notacorrente)) { System.out.println("Loja " + notaAnterior.getLoja() + " Numero: " + numero); naoEncontradas.add(notacorrente); msg = msg.concat(" Loja: " + notacorrente.getLoja() + " Nota: " + notacorrente.getNumero() + " Serie: " + notacorrente.getSerie() + " \n"); } } } } } if (naoEncontradas.size() > 0) { Email email = new SimpleEmail(); email.setHostName(hostEmail); email.setSmtpPort(Integer.parseInt(portEmail)); email.setAuthentication(userEmail, passEmail); email.setFrom(fromEmail); email.setSubject("Alerta Nerus!!"); email.setMsg(msg); email.addTo(toEmail); email.send(); } } catch (Exception ex) { Logger.getLogger(NotaBO.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.github.frapontillo.pulse.email.EmailNotifier.java
/** * Send an email, using the provided parameters, notifying if the pipeline succeeded or errored. * * @param parameters The {@link EmailNotifierConfig} to use. * @param isSuccess {@code true} to report a success, {@code false} to report an error. *///from w w w. jav a2 s . c om private void sendEmail(EmailNotifierConfig parameters, boolean isSuccess) { if (parameters.getAddresses() == null || parameters.getAddresses().length == 0) { return; } try { Email email = new SimpleEmail(); email.setHostName(parameters.getHost()); email.setSmtpPort(parameters.getPort()); email.setAuthenticator(new DefaultAuthenticator(parameters.getUsername(), parameters.getPassword())); email.setSSLOnConnect(parameters.getUseSsl()); email.setFrom(parameters.getFrom()); email.setSubject(parameters.getSubject()); String body; if (isSuccess) { body = parameters.getBodySuccess(); } else { body = parameters.getBodyError(); } body = body.replace("{{NAME}}", getProcessInfo().getName()); email.setMsg(body); email.addTo(parameters.getAddresses()); email.send(); } catch (EmailException e) { logger.error(e); e.printStackTrace(); } }
From source file:com.ning.billing.util.email.DefaultEmailSender.java
private void sendEmail(final List<String> to, final List<String> cc, final String subject, final Email email) throws EmailApiException { try {//from w w w . ja v a 2 s . c o m email.setSmtpPort(config.getSmtpPort()); if (config.useSmtpAuth()) { email.setAuthentication(config.getSmtpUserName(), config.getSmtpPassword()); } email.setHostName(config.getSmtpServerName()); email.setFrom(config.getDefaultFrom()); email.setSubject(subject); if (to != null) { for (final String recipient : to) { email.addTo(recipient); } } if (cc != null) { for (final String recipient : cc) { email.addCc(recipient); } } email.setSSL(config.useSSL()); log.info("Sending email to {}, cc {}, subject {}", new Object[] { to, cc, subject }); email.send(); } catch (EmailException ee) { throw new EmailApiException(ee, ErrorCode.EMAIL_SENDING_FAILED); } }
From source file:com.kylinolap.common.util.MailService.java
/** * //from w w w.java2s . c o m * @param receivers * @param subject * @param content * @return true or false indicating whether the email was delivered successfully * @throws IOException */ public boolean sendMail(List<String> receivers, String subject, String content) throws IOException { if (!enabled) { logger.info("Email service is disabled; this mail will not be delivered: " + subject); logger.info("To enable mail service, set 'mail.enabled=true' in kylin.properties"); return false; } Email email = new HtmlEmail(); email.setHostName(host); if (username != null && username.trim().length() > 0) { email.setAuthentication(username, password); } //email.setDebug(true); try { for (String receiver : receivers) { email.addTo(receiver); } email.setFrom(sender); email.setSubject(subject); email.setCharset("UTF-8"); ((HtmlEmail) email).setHtmlMsg(content); email.send(); email.getMailSession(); } catch (EmailException e) { logger.error(e.getLocalizedMessage(), e); return false; } return true; }
From source file:com.patrolpro.beans.SignupClientBean.java
public String sendEmail() { try {/*from ww w . java2s. co m*/ boolean isValid = validateInformation(); if (isValid) { StringBuilder emailMessage = new StringBuilder(); emailMessage.append("Contact Name: " + this.contactName + "\r\n"); emailMessage.append("Contact Email: " + this.contactEmail + "\r\n"); emailMessage.append("Contact Phone: " + this.contactPhone + "\r\n"); emailMessage.append("Company Name: " + this.companyName + "\r\n"); emailMessage.append(message); Email htmlEmail = new SimpleEmail(); if (message == null || message.length() == 0) { message = "No message was provided by the user."; } htmlEmail.setFrom("signup@patrolpro.com"); htmlEmail.setSubject("Trial Account Email!"); htmlEmail.addTo("rharris@ainteractivesolution.com"); htmlEmail.addTo("ijuneau@ainteractivesolution.com"); htmlEmail.addCc("jc@champ.net"); //htmlEmail.setHtmlMsg(emailMessage.toString()); htmlEmail.setMsg(emailMessage.toString()); //htmlEmail.setTextMsg(emailMessage.toString()); htmlEmail.setDebug(true); htmlEmail.setAuthenticator(new MailAuthenticator("schedfox", "Sch3dF0x4m3")); htmlEmail.setHostName("mail2.champ.net"); htmlEmail.setSmtpPort(587); htmlEmail.send(); return "sentEmail"; } } catch (Exception exe) { } return "invalid"; }