List of usage examples for org.apache.commons.mail HtmlEmail setTextMsg
public HtmlEmail setTextMsg(final String aText) throws EmailException
From source file:de.maklerpoint.office.Marketing.Tools.SendNewsletter.java
/** * * @param nl/*from w w w . j a v a 2 s .co m*/ * @param temail * @throws EmailException */ public static void sendTestNewsletter(NewsletterObj nl, String temail) throws EmailException { HtmlEmail email = new HtmlEmail(); email.setHostName(Config.get("mailHost", null)); if (Config.getConfigInt("mailPort", 25) != 25) email.setSmtpPort(Config.getConfigInt("mailPort", 25)); if (Config.getConfigBoolean("mailAuth", true)) email.setAuthentication(Config.get("mailUser", null), Config.get("mailPassword", null)); email.setFrom(nl.getSenderMail(), nl.getSender()); email.setSubject(nl.getSubject()); email.setHtmlMsg(nl.getText()); email.setTextMsg("Ihr E-Mail Client untersttzt keine HTML Nachrichten."); email.addTo(temail); email.send(); }
From source file:de.maklerpoint.office.Marketing.Tools.SendNewsletter.java
/** * //from ww w .j a va 2 s . c o m * @param nl * @param sub * @throws EmailException */ public static void sendNewsletter(NewsletterObj nl, NewsletterSubscriberObj[] sub) throws EmailException { for (int i = 0; i < sub.length; i++) { HtmlEmail email = new HtmlEmail(); email.setHostName(Config.get("mailHost", null)); if (Config.getConfigInt("mailPort", 25) != 25) email.setSmtpPort(Config.getConfigInt("mailPort", 25)); if (Config.getConfigBoolean("mailAuth", true)) email.setAuthentication(Config.get("mailUser", null), Config.get("mailPassword", null)); email.setFrom(nl.getSenderMail(), nl.getSender()); email.setSubject(nl.getSubject()); email.setHtmlMsg(nl.getText()); email.setTextMsg("Ihr E-Mail Client untersttzt keine HTML Nachrichten."); email.addTo(sub[i].getEmail(), sub[i].getName()); email.send(); } }
From source file:com.bytecode.util.SendEmail.java
static boolean sendADEmail(Email msg) { boolean sent = false; try {//w w w.ja v a 2 s . c o m // Create the email message HtmlEmail email = new HtmlEmail(); email.setHostName("172.16.10.184"); email.setSmtpPort(25); email.addTo(msg.getEmailAddress()); email.setFrom("twofactor@unionbankng.com", "Union Bank"); if (msg.getSubject().equalsIgnoreCase("SPECIAL")) { email.setSubject("MANUAL ACTIVATION"); } else { email.setSubject("Two Factor Authentication Details"); } String formattedEmail = formatEmail(msg.getMessage()); // set the html message email.setHtmlMsg(formattedEmail); // set the alternative message email.setTextMsg("Your email client does not support HTML messages"); // send the email Log.l.infoLog.info("Sending email to " + msg.getEmailAddress()); String response = email.send(); sent = true; Log.l.infoLog.info("Email Sent to :" + msg.getEmailAddress() + " Response:" + response); return sent; } catch (EmailException ex) { Log.l.infoLog.info(ex); return sent; } catch (Exception ex) { Log.l.infoLog.info(ex); return sent; } }
From source file:br.com.dedoduro.util.EnviarEmail.java
/** * Enviar o email para a lista de usarios especificados * @param emails/*from ww w . j ava 2 s. com*/ * @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/*w w w . java2s.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: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 ww .ja v a2 s . co m 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:function.Email.java
public static void sendOrderEmail(String OrderID, String CustomnerEmail) { try {//from w w w . ja v a 2s .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 ww. j a v a 2s . c o 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(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:com.sigaf.bean.MailReset.java
public static void enviaEmail(TUsuario usuario, String URI) throws EmailException, MalformedURLException { HtmlEmail email; email = conectaEmail();//from w w w . j a v a 2 s .c om email.setSubject("Restablece tu contrasea"); // URL url = new URL("http://www.apache.org/images/asf_logo_wide.gif"); // String cid2 = email.embed(url, "logo ??.gif"); email.setHtmlMsg("<html>\n" + " <head>\n" + " <title>Restablece tu contrasea</title>\n" + " </head>\n" + " <body>\n" + " <p>Hemos recibido una peticin para restablecer la contrasea de tu cuenta.</p>\n" + " <p>Si hiciste esta peticin, haz clic en el siguiente enlace, si no hiciste esta peticin puedes ignorar este correo.</p>\n" + " <p>\n" + " <strong>Enlace para restablecer tu contrasea</strong><br>\n" + " <a href='" + URI + "'> Restablecer contrasea </a>\n" + " </p>\n" + " </body>\n" + "\n" + " </html>"); email.setTextMsg("Your email client does not support HTML messages"); email.addTo(usuario.getTEmpleado().getCorreoEmpleado()); email.send(); }
From source file:mailbox.EmailHandler.java
private static void reply(IMAPMessage origin, String username, String emailAddress, String msg) { final HtmlEmail email = new HtmlEmail(); try {//from www. j a va 2 s . co m email.setFrom(Config.getEmailFromSmtp(), Config.getSiteName()); email.addTo(emailAddress, username); String subject; if (!origin.getSubject().toLowerCase().startsWith("re:")) { subject = "Re: " + origin.getSubject(); } else { subject = origin.getSubject(); } email.setSubject(subject); email.setTextMsg(msg); email.setCharset("utf-8"); email.setSentDate(new Date()); email.addHeader("In-Reply-To", origin.getMessageID()); email.addHeader("References", origin.getMessageID()); Mailer.send(email); String escapedTitle = email.getSubject().replace("\"", "\\\""); String logEntry = String.format("\"%s\" %s", escapedTitle, email.getToAddresses()); play.Logger.of("mail").info(logEntry); } catch (Exception e) { Logger.warn("Failed to send an email: " + email + "\n" + ExceptionUtils.getStackTrace(e)); } }