List of usage examples for org.apache.commons.mail HtmlEmail setAuthenticator
public void setAuthenticator(final Authenticator newAuthenticator)
Authenticator
to be used when authentication is requested from the mail server. From source file:com.sigaf.bean.MailReset.java
public static HtmlEmail conectaEmail() throws EmailException { HtmlEmail email = new HtmlEmail(); email.setHostName(HOSTNAME);// w w w. j a va2 s . c o m email.setSmtpPort(587); email.setSSL(true); email.setAuthenticator(new DefaultAuthenticator(USERNAME, PASSWORD)); email.setTLS(true); email.setFrom(EMAILORIGEM); return email; }
From source file:function.Email.java
public static void sendOrderEmail(String OrderID, String CustomnerEmail) { try {/* w w w . java2 s . co m*/ HtmlEmail email = new HtmlEmail(); email.setHostName("smtp.googlemail.com"); email.setSmtpPort(465); email.setAuthenticator(new DefaultAuthenticator(MY_EMAIL, MY_PASSWORD)); email.setSSLOnConnect(true); email.setFrom(MY_EMAIL); email.addTo(CustomnerEmail); email.setSubject("Thanh ton thnh cng."); email.setHtmlMsg("<html><h2>Ha n ca bn vi m ha n <font color='red'>" + OrderID + "</font> thanh ton thnh cng.</h2>" + "<b>Cm n bn ng h chng ti!!!</b></div>" + "</html>"); email.setCharset("UTF-8"); email.setTextMsg("Trnh duyt khng h tr nh dng html!"); String a = email.send(); System.out.println(a); } catch (EmailException eex) { System.err.println(eex); } }
From source file:function.Email.java
public static void sendVerifyEmail(Customers customer, String hash) { try {//from w w w . jav a 2 s .com HtmlEmail email = new HtmlEmail(); email.setHostName("smtp.googlemail.com"); email.setSmtpPort(465); email.setAuthenticator(new DefaultAuthenticator(MY_EMAIL, MY_PASSWORD)); email.setSSLOnConnect(true); email.setFrom(MY_EMAIL); email.addTo(customer.getEmail()); email.setSubject("Xc nhn ti khon TiviStore"); email.setHtmlMsg("<html><h2>Cho " + customer.getCustomerName() + ",</h2>" + "<div><b>Vui lng click vo <a href='http://localhost:8084/ThuongMaiDienTu/Verify?u=" + customer.getCustomerID() + "&hash=" + hash + "'>y</a> xc nhn ti khon...</b></div><br />" + "<b>Cm n bn ng h!!!</b></div>" + "</html>"); email.setCharset("UTF-8"); email.setTextMsg("Trnh duyt khng h tr nh dng html!"); String a = email.send(); System.out.println(a); } catch (EmailException eex) { System.err.println(eex); } }
From source file:gribbit.util.SendEmail.java
/** Send an email. Don't forget to use fully-qualified URLs in the message body. */ public static void sendEmail(final String toName, final String to, final String subject, final DataModel message, final String messagePlainText) { // Queue sending of email in a new thread GribbitServer.vertx.executeBlocking(future -> { if (GribbitProperties.SMTP_SERVER == null || GribbitProperties.SEND_EMAIL_ADDRESS == null || GribbitProperties.SEND_EMAIL_PASSWORD == null || GribbitProperties.SEND_EMAIL_ADDRESS == null || GribbitProperties.SEND_EMAIL_NAME == null) { throw new RuntimeException("SMTP is not fully configured in the properties file"); }/*w w w.j av a 2s . c om*/ String fullEmailAddr = "\"" + toName + "\" <" + to + ">"; try { HtmlEmail email = new ImageHtmlEmail(); email.setDebug(false); email.setHostName(GribbitProperties.SMTP_SERVER); email.setSmtpPort(GribbitProperties.SMTP_PORT); email.setAuthenticator(new DefaultAuthenticator(GribbitProperties.SEND_EMAIL_ADDRESS, GribbitProperties.SEND_EMAIL_PASSWORD)); email.setStartTLSRequired(true); email.addTo(to, toName); email.setFrom(GribbitProperties.SEND_EMAIL_ADDRESS, GribbitProperties.SEND_EMAIL_NAME); email.setSubject(subject); email.setHtmlMsg(message.toString()); email.setTextMsg(messagePlainText); email.send(); Log.info("Sent email to " + fullEmailAddr + " : " + subject); } catch (EmailException e) { Log.exception("Failure while trying to send email to " + fullEmailAddr + " : " + subject, e); } future.complete(); }, res -> { if (res.failed()) { Log.error("Exception while trying to send email"); } }); }
From source file:br.com.dedoduro.util.EnviarEmail.java
/** * Enviar o email para a lista de usarios especificados * @param emails// www . j a va 2 s . c o m * @param assunto * @param conteudo */ private static void tratarEnvio(ArrayList<String> emails, String assunto, String conteudo) { HtmlEmail email = new HtmlEmail(); try { email.setHostName(Constantes.HOST_NAME_GMAIL); email.addTo(Constantes.ADMINISTRADOR_1); email.setFrom(Constantes.EMAIL_REMETENTE_GMAIL, "Administrador"); for (String tmp : emails) { email.addBcc(tmp); } email.setSubject(assunto); // Trabalhando com imagem... // URL url = new URL ("http://<ENDERECO DA IMAGEM AQUI...>"); // String idImg = email.embed(url, "logo"); email.setHtmlMsg(conteudo); // Tratando mensagem alternativa email.setTextMsg("Seu servidor de e-mail no suporta mensagem HTML... :-("); email.setSmtpPort(Constantes.PORTA_SMTP_GMAIL); email.setAuthenticator( new DefaultAuthenticator(Constantes.EMAIL_REMETENTE_GMAIL, Constantes.SENHA_REMETENTE_GMAIL)); email.setSSLOnConnect(true); // Enviando email email.send(); } catch (EmailException e) { e.printStackTrace(); } }
From source file:br.com.smarttaco.util.EnviarEmail.java
/** * Enviar o email para a lista de usarios especificados * @param emails/*from www . j a va 2 s . c om*/ * @param assunto * @param conteudo */ public static void tratarEnvio(ArrayList<String> emails, String assunto, String conteudo) { HtmlEmail email = new HtmlEmail(); try { email.setHostName(Constantes.HOST_NAME_GMAIL); email.addTo(Constantes.ADMINISTRADOR_1); email.setFrom(Constantes.EMAIL_REMETENTE_GMAIL, "SmartTaco - Administrador"); for (String tmp : emails) { email.addBcc(tmp); } email.setSubject(assunto); // Trabalhando com imagem... // URL url = new URL ("http://<ENDERECO DA IMAGEM AQUI...>"); // String idImg = email.embed(url, "logo"); email.setHtmlMsg(conteudo); // Tratando mensagem alternativa email.setTextMsg("Seu servidor de e-mail no suporta mensagem HTML... :-("); email.setSmtpPort(Constantes.PORTA_SMTP_GMAIL); email.setAuthenticator( new DefaultAuthenticator(Constantes.EMAIL_REMETENTE_GMAIL, Constantes.SENHA_REMETENTE_GMAIL)); email.setSSLOnConnect(true); // Enviando email email.send(); } catch (EmailException e) { e.printStackTrace(); } }
From source file:libs.BuildMail.java
private void sendMail(String address, String subject, String msg) { try {// w ww . j a v a 2 s.c o m HtmlEmail email = new HtmlEmail(); email.setHostName("smtp.ufpa.br"); email.setSmtpPort(25); email.setAuthenticator(new DefaultAuthenticator("david.lopes@icen.ufpa.br", "spiderteste")); //email.setSSLOnConnect(); TODO verficar a possiblidade de uso SMTP email.setFrom("david.lopes@icen.ufpa.br"); email.setSubject(subject); email.addTo(address); email.setHtmlMsg(msg); email.send(); } catch (EmailException error) { System.out.println("Email error: check your log file" + error.getMessage()); } }
From source file:io.mif.labanorodraugai.services.EmailService.java
private void setUpHtmlEmail(HtmlEmail email) throws EmailException { email.setHostName("smtp.googlemail.com"); email.setSmtpPort(465);//from w w w .j a v a 2 s . c om email.setAuthenticator(new DefaultAuthenticator("labanorodraugaibendrija@gmail.com", "labanoro123")); email.setSSLOnConnect(true); email.setCharset("UTF-8"); email.setFrom("labanorodraugaibendrija@gmail.com", "Labanoro draugai"); }
From source file:com.fatecib.projetoemail.servlets.DAO.Enviaremail2.java
private void enviar(Email em, ConfiguracaoSQL conf, String destinatario) throws EmailException { try {// w ww.j a v a 2 s.com HtmlEmail email = new HtmlEmail(); email.setHostName(conf.getEMAILHOST()); email.setSmtpPort(conf.getPORTASMTP()); email.setAuthenticator(new DefaultAuthenticator(conf.getUsuario(), conf.getSENHA())); email.setSSL(true); email.setFrom(conf.getUsuario()); email.setSubject(em.getTitulo()); email.setHtmlMsg(em.getConteudo()); // set the alternative message email.setTextMsg("Email enviado com sucesso"); email.addTo(destinatario); email.send(); } catch (Exception e) { throw e; } }
From source file:be.thomasmore.controller.EmailController.java
public String sendEmail() throws EmailException { Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext() .getRequestParameterMap();/*from w w w . j a v a2s. c o m*/ String id = params.get("studentId"); int studentId = Integer.parseInt(id); Student student = service.getStudent(studentId); HtmlEmail email = new HtmlEmail(); email.setHostName("smtp.gmail.com"); email.setSmtpPort(587); email.setAuthenticator(new DefaultAuthenticator("pointernulltest@gmail.com", "r0449914")); email.setSSLOnConnect(true); email.addTo(student.getEmail(), student.getNaam() + " " + student.getVoornaam()); email.setFrom("me@apache.org", "Thomas More Geel"); email.setSubject("Rapport"); StringBuffer msg = new StringBuffer(); msg.append("<html><body>"); msg.append("<h2>Resultaten</h2>"); List<Score> scores = student.getScoreList(); msg.append("<p>Beste " + student.getVoornaam() + " " + student.getNaam() + " hieronder vind je je punten voor afgelopen semester."); for (Score score : scores) { msg.append("<p>"); msg.append(score.getTestId().getVakId().getNaam() + " " + score.getTestId().getBeschrijving() + " : " + score.getScore()); msg.append("</p>"); msg.append("</body></html>"); } email.setHtmlMsg(msg.toString()); email.send(); return null; }