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:br.com.itfox.utils.SendHtmlFormatedEmail.java
public void sendingHtml(String orderDetails, String orderNumber, String toName, String toEmail) { try {/*from w w w. ja va2 s .c om*/ // Create the email message HtmlEmail email = new HtmlEmail(); email.setHostName("smtp.gmail.com"); email.setSmtpPort(587); email.setAuthenticator(new DefaultAuthenticator("belchiorpalma@gmail.com", "xp2002b5")); email.setSSLOnConnect(true); email.setTLS(true); email.setFrom("contato@itfox.com.br"); //email.setSubject("TestMail"); email.addTo(toEmail, toName); //email.setFrom("belchiorpalma@me.com", "Me"); //email.setSubject("Test email with inline image"); email.setSubject(MimeUtility.encodeText("Thank you for your order", "UTF-8", "B")); // embed the image and get the content id //URL url = new URL("http://boutiquecellars.com/img/white-wines.jpg"); //String cid = email.embed(url, "BoutiqueCellars.com"); // set the html message email.setHtmlMsg("Thank you for your order\n<br/><br/>" + "\n" + "We received your order #" + orderNumber + " and we are working on it now.\n<br/>" + "We will e-mail you an update as soon as your order is processed.\n<br/>" + "\n<br/>" + "Boutique Cellars team\n" + "\n<br/><br/><img src='http://boutiquecellars.com/img/logoemail.jpg'/> \n" + //orderDetails + "<br/><br/>BOUTIQUE CELLARS SUPPORTS THE RESPONSIBLE SERVICE OF ALCOHOL. NSW: UNDER THE LIQUOR\n<br/>" + "ACT 2007 IT IS AGAINST THE LAW TO SELL OR SUPPLY ALCOHOL TO, OR TO OBTAIN ALCOHOL ON\n<br/>" + "BEHALF OF, A PERSON UNDER THE AGE OF 18 YEARS. NSW PACKAGED LIQUOR LICENCE NUMBER\n<br/>" + "LIQP770016947. YOUR CONTRACT OF SALE IS WITH THE RELEVANT LICENSEE AT THE RELEVANT\n<br/>" + "PREMISES FROM WHICH YOU ORDER IS ACCEPTED AND FULFILLED. LIQUOR IS SOLD FROM OUR\n<br/>" + "PLATFORM ON BEHALF OF THE RELEVANT LICENSEE. ACCORDINGLY, YOUR OFFER TO PURCHASE IS\n<br/>" + "SUBJECT TO ACCEPTANCE OF YOUR OFFER BY THE HOLDER OF THE LIQUOR LICENCE, CERTIFICATION\n<br/>" + "AND EVIDENCE OF YOU BEING OVER 18 YEARS OF AGE, THE AVAILABILITY OF STOCK AND THE\n<br/>" + "LIQUOR WHICH IS THE SUBJECT MATTER OF YOUR OFFER BEING ASCERTAINED AND APPROPRIATED\n<br/>" + "AT THE ABOVE MENTIONED LICENSED PREMISES.<br/><br/>" + " Boutique Cellar Imports Pty Ltd | ABN 69 607 265 618"); // set the alternative message email.setTextMsg( "Thank you for your order, We received your order #18765 and we are working on it now.\n" + "We will e-mail you an update as soon as your order is processed.\n" + "\n" + "Boutique Cellars team"); // send the email email.send(); } catch (EmailException ex) { Logger.getLogger(SendHtmlFormatedEmail.class.getName()).log(Level.SEVERE, null, ex); } catch (UnsupportedEncodingException ex) { Logger.getLogger(SendHtmlFormatedEmail.class.getName()).log(Level.SEVERE, null, ex); } /*} catch (MalformedURLException ex) { Logger.getLogger(SendHtmlFormatedEmail.class.getName()).log(Level.SEVERE, null, ex); }*/ }
From source file:email.cadastro.EmailCadastro.java
public boolean EnviarCodConfirmacao(String codigo, String emailCadastro) { HtmlEmail email = new HtmlEmail(); email.setSSLOnConnect(true);/* w w w. jav a 2s .com*/ email.setHostName("smtp.gmail.com"); //email.setSslSmtpPort("465"); email.setAuthenticator(new DefaultAuthenticator("contatogamesapp@gmail.com", "gamesifsul")); try { email.setFrom("contatogamesapp@gmail.com", "Equipe GamesApp"); email.setDebug(true); email.setSubject("Cdigo de confirmao"); String emailHtml = "<!doctype html><html><head><meta charset=\"UTF-8\"><meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><title>Email</title></head><style type=\"text/css\">p{margin:10px 0;padding:0;}table{border-collapse:collapse;}h1,h2,h3,h4,h5,h6{display:block;margin:0;padding:0;}img,a img{border:0;height:auto;outline:none;text-decoration:none;}body,#bodyTable,#bodyCell{height:100%;margin:0;padding:0;width:100%;}#outlook a{padding:0;}img{-ms-interpolation-mode:bicubic;}table{mso-table-lspace:0pt;mso-table-rspace:0pt;}.ReadMsgBody{width:100%;}.ExternalClass{width:100%;}p,a,li,td,blockquote{mso-line-height-rule:exactly;}a[href^=tel],a[href^=sms]{color:inherit;cursor:default;text-decoration:none;}p,a,li,td,body,table,blockquote{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;}.ExternalClass,.ExternalClass p,.ExternalClass td,.ExternalClass div,.ExternalClass span,.ExternalClass font{line-height:100%;}a[x-apple-data-detectors]{color:inherit !important;text-decoration:none !important;font-size:inherit !important;font-family:inherit !important;font-weight:inherit !important;line-height:inherit !important;}#bodyCell{padding:10px;}.templateContainer{max-width:600px !important;}a.mcnButton{display:block;}.mcnImage{vertical-align:bottom;}.mcnTextContent{word-break:break-word;}.mcnTextContent img{height:auto !important;}.mcnDividerBlock{table-layout:fixed !important;}body,#bodyTable{background-color:#FAFAFA;}#bodyCell{border-top:0;}.templateContainer{border:0;}h1{color:#616161;font-family:Helvetica;font-size:22px;font-style:normal;font-weight:bold;line-height:125%;letter-spacing:normal;text-align:left;}h2{color:#202020;font-family:Helvetica;font-size:22px;font-style:normal;font-weight:bold;line-height:125%;letter-spacing:normal;text-align:left;}h3{color:#202020;font-family:Helvetica;font-size:20px;font-style:normal;font-weight:bold;line-height:125%;letter-spacing:normal;text-align:left;}h4{color:#202020;font-family:Helvetica;font-size:18px;font-style:normal;font-weight:bold;line-height:125%;letter-spacing:normal;text-align:left;}#templatePreheader{background-color:#FAFAFA;border-top:0;border-bottom:0;padding-top:20px;padding-bottom:20px;}#templatePreheader .mcnTextContent,#templatePreheader .mcnTextContent p{color:#656565;font-family:Helvetica;font-size:12px;line-height:150%;text-align:left;}#templatePreheader .mcnTextContent a,#templatePreheader .mcnTextContent p a{color:#656565;font-weight:normal;text-decoration:underline;}#templateHeader{background-color:#FFFFFF;border-top:0;border-bottom:0;padding-top:9px;padding-bottom:0;}#templateHeader .mcnTextContent,#templateHeader .mcnTextContent p{color:#202020;font-family:Helvetica;font-size:16px;line-height:150%;text-align:left;}#templateHeader .mcnTextContent a,#templateHeader .mcnTextContent p a{color:#2BAADF;font-weight:normal;text-decoration:underline;}#templateBody{background-color:#FFFFFF;border-top:0;border-bottom:2px solid #EAEAEA;padding-top:0;padding-bottom:9px;}#templateBody .mcnTextContent,#templateBody .mcnTextContent p{color:#616161;font-family:Helvetica;font-size:16px;line-height:150%;text-align:left;}#templateBody .mcnTextContent a,#templateBody .mcnTextContent p a{color:#2BAADF;font-weight:normal;text-decoration:underline;}#templateFooter{background-color:#FAFAFA;border-top:0;border-bottom:0;padding-top:9px;padding-bottom:9px;}#templateFooter .mcnTextContent,#templateFooter .mcnTextContent p{color:#656565;font-family:Helvetica;font-size:12px;line-height:150%;text-align:center;}#templateFooter .mcnTextContent a,#templateFooter .mcnTextContent p a{color:#656565;font-weight:normal;text-decoration:underline;}button{background: #107a49; border: none; padding: 10px 20px; border-radius: 70px; color: #fff;margin-top: 30px;cursor: pointer;}@media only screen and (min-width:768px){.templateContainer{width:600px !important;}}@media only screen and (max-width: 480px){body,table,td,p,a,li,blockquote{-webkit-text-size-adjust:none !important;}}@media only screen and (max-width: 480px){body{width:100% !important;min-width:100% !important;}}@media only screen and (max-width: 480px){#bodyCell{padding-top:10px !important;}}@media only screen and (max-width: 480px){.mcnImage{width:100% !important;}}@media only screen and (max-width: 480px){.mcnCartContainer,.mcnCaptionTopContent,.mcnRecContentContainer,.mcnCaptionBottomContent,.mcnTextContentContainer,.mcnBoxedTextContentContainer,.mcnImageGroupContentContainer,.mcnCaptionLeftTextContentContainer,.mcnCaptionRightTextContentContainer,.mcnCaptionLeftImageContentContainer,.mcnCaptionRightImageContentContainer,.mcnImageCardLeftTextContentContainer,.mcnImageCardRightTextContentContainer{max-width:100% !important;width:100% !important;}}@media only screen and (max-width: 480px){.mcnBoxedTextContentContainer{min-width:100% !important;}}@media only screen and (max-width: 480px){.mcnImageGroupContent{padding:9px !important;}}@media only screen and (max-width: 480px){.mcnCaptionLeftContentOuter .mcnTextContent,.mcnCaptionRightContentOuter .mcnTextContent{padding-top:9px !important;}}@media only screen and (max-width: 480px){.mcnImageCardTopImageContent,.mcnCaptionBlockInner .mcnCaptionTopContent:last-child .mcnTextContent{padding-top:18px !important;}}@media only screen and (max-width: 480px){.mcnImageCardBottomImageContent{padding-bottom:9px !important;}}@media only screen and (max-width: 480px){.mcnImageGroupBlockInner{padding-top:0 !important;padding-bottom:0 !important;}}@media only screen and (max-width: 480px){.mcnImageGroupBlockOuter{padding-top:9px !important;padding-bottom:9px !important;}}@media only screen and (max-width: 480px){.mcnTextContent,.mcnBoxedTextContentColumn{padding-right:18px !important;padding-left:18px !important;}}@media only screen and (max-width: 480px){.mcnImageCardLeftImageContent,.mcnImageCardRightImageContent{padding-right:18px !important;padding-bottom:0 !important;padding-left:18px !important;}}@media only screen and (max-width: 480px){.mcpreview-image-uploader{display:none !important;width:100% !important;}}@media only screen and (max-width: 480px){h1{font-size:22px !important;line-height:125% !important;}}@media only screen and (max-width: 480px){h2{font-size:20px !important;line-height:125% !important;}}@media only screen and (max-width: 480px){h3{font-size:18px !important;line-height:125% !important;}}@media only screen and (max-width: 480px){h4{font-size:16px !important;line-height:150% !important;}}@media only screen and (max-width: 480px){.mcnBoxedTextContentContainer .mcnTextContent,.mcnBoxedTextContentContainer .mcnTextContent p{font-size:14px !important;line-height:150% !important;}}@media only screen and (max-width: 480px){#templatePreheader{display:block !important;}}@media only screen and (max-width: 480px){#templatePreheader .mcnTextContent,#templatePreheader .mcnTextContent p{font-size:14px !important;line-height:150% !important;}}@media only screen and (max-width: 480px){#templateHeader .mcnTextContent,#templateHeader .mcnTextContent p{font-size:16px !important;line-height:150% !important;}}@media only screen and (max-width: 480px){#templateBody .mcnTextContent,#templateBody .mcnTextContent p{font-size:16px !important;line-height:150% !important;}}@media only screen and (max-width: 480px){#templateFooter .mcnTextContent,#templateFooter .mcnTextContent p{font-size:14px !important;line-height:150% !important;}}</style><body><center><table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" height=\"100%\" width=\"100%\" id=\"bodyTable\"><tr><td align=\"center\" valign=\"top\" id=\"bodyCell\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class=\"templateContainer\"><tr><td valign=\"top\" id=\"templatePreheader\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class=\"mcnImageBlock\" style=\"min-width:100%;\"><tbody class=\"mcnImageBlockOuter\"><tr><td valign=\"top\" style=\"padding:9px\" class=\"mcnImageBlockInner\"><table align=\"left\" width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"mcnImageContentContainer\" style=\"min-width:100%;\"><tbody><tr><td class=\"mcnImageContent\" valign=\"top\" style=\"padding-right: 9px; padding-left: 9px; padding-top: 0; padding-bottom: 0;\"><a href=\"https://github.com/GamesApp\" target=\"_blank\"><img align=\"left\" alt=\"\" src=\"https://ap.imagensbrasil.org/images/2016/11/21/logo_escrita.png\" width=\"200\" style=\"max-width:200px; padding-bottom: 0; display: inline !important; vertical-align: bottom;\" class=\"mcnImage\"></a></td></tr></tbody></table></td></tr></tbody></table></td></tr><tr><td valign=\"top\" id=\"templateBody\" style=\"border-radius:5px;\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class=\"mcnTextBlock\" style=\"min-width:100%;\"><tbody class=\"mcnTextBlockOuter\"><tr><td valign=\"top\" class=\"mcnTextBlockInner\" style=\"padding-top:9px;\"><table align=\"left\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"max-width:100%; min-width:100%;\" width=\"100%\" class=\"mcnTextContentContainer\"><tbody><tr><td valign=\"top\" class=\"mcnTextContent\" style=\"padding-top:30px; padding-right:30px; padding-bottom:30px; padding-left:30px;\"><h1>Cdigo de confirmao</h1><p>E a, tudo certo?!</p><p>Recebemos uma solicitao de cadastro no aplicativo GamesApp.</p><p>Segue o cdigo de confirmao:</p><div style=\"background: #CCCCCC; text-align: center; border-radius:5px; padding-top: 9px; padding-bottom: 9px;\">" + codigo + "</div><p style=\"font-size: 10px; \">Obs.: Se voc no realizou est operao entrar em contato o mais rpido possvel!</p></td></tr></tbody></table></td></tr></tbody></table><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class=\"mcnDividerBlock\" style=\"min-width:100%;\"><tbody class=\"mcnDividerBlockOuter\"><tr><td class=\"mcnDividerBlockInner\" style=\"min-width:100%; padding:18px 30px;\"><table class=\"mcnDividerContent\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" style=\"min-width: 100%;border-top: 2px dashed #EAEAEA;\"><tbody><tr><td><span></span></td></tr></tbody></table></td></tr></tbody></table><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class=\"mcnFollowBlock\" style=\"min-width:100%;\"><tbody class=\"mcnFollowBlockOuter\"><tr><td align=\"center\" valign=\"top\" style=\"padding:9px\" class=\"mcnFollowBlockInner\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class=\"mcnFollowContentContainer\" style=\"min-width:100%;\"><tbody><tr><td align=\"center\" style=\"padding-left:9px;padding-right:9px;\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" style=\"min-width:100%;\" class=\"mcnFollowContent\"><tbody><tr><td align=\"center\" valign=\"top\" style=\"padding-top:9px; padding-right:9px; padding-left:9px;\"><table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tbody><tr><td align=\"center\" valign=\"top\"><table align=\"left\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"display:inline;\"><tbody><tr><td valign=\"top\" style=\"padding-right:0; padding-bottom:9px;\" class=\"mcnFollowContentItemContainer\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class=\"mcnFollowContentItem\"><tbody><tr><td align=\"left\" valign=\"middle\" style=\"padding-top:5px; padding-right:10px; padding-bottom:5px; padding-left:9px;\"><table align=\"left\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"\"><tbody><tr><td align=\"center\" valign=\"middle\" width=\"24\" class=\"mcnFollowIconContent\"><a href=\"https://github.com/GamesApp\" target=\"_blank\"><img src=\"http://oi63.tinypic.com/30sk57c.jpg\" style=\"display:block;\" height=\"24\" width=\"24\" class=\"\"></a></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr><tr><td valign=\"top\" id=\"templateFooter\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class=\"mcnTextBlock\" style=\"min-width:100%;\"><tbody class=\"mcnTextBlockOuter\"><tr><td valign=\"top\" class=\"mcnTextBlockInner\" style=\"padding-top:9px;\"><table align=\"left\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"max-width:100%; min-width:100%;\" width=\"100%\" class=\"mcnTextContentContainer\"><tbody><tr><td valign=\"top\" class=\"mcnTextContent\" style=\"padding-top:0; padding-right:18px; padding-bottom:9px; padding-left:18px;\"><em> GamesApp. Todos os direitos reservados. </em><br><br></td></tr></tbody></table></td></tr></tbody></table></td></tr></table></td></tr></table></center></body></html>"; email.setHtmlMsg(emailHtml); email.addTo(emailCadastro); email.send(); } catch (EmailException e) { return false; } return true; }
From source file:com.hangum.tadpold.commons.libs.core.mails.SendEmails.java
/** * send email//from w ww. j a v a 2s .c om * * @param emailDao */ public void sendMail(EmailDTO emailDao) throws Exception { if (logger.isDebugEnabled()) logger.debug("Add new message"); try { // MailcapCommandMap mc = (MailcapCommandMap) CommandMap.getDefaultCommandMap(); // mc.addMailcap("text/html;; x-java-content-handler=com.sun.mail.handlers.text_html"); // mc.addMailcap("text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml"); // mc.addMailcap("text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain"); // mc.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed"); // mc.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822"); // CommandMap.setDefaultCommandMap(mc); HtmlEmail email = new HtmlEmail(); email.setHostName(smtpDto.getHost()); email.setSmtpPort(NumberUtils.toInt(smtpDto.getPort())); email.setAuthenticator(new DefaultAuthenticator(smtpDto.getEmail(), smtpDto.getPasswd())); email.setSSLOnConnect(true); email.setFrom(smtpDto.getEmail(), "Tadpole DB Hub"); email.setSubject(emailDao.getSubject()); // set the html message email.setHtmlMsg(emailDao.getContent()); email.addTo(emailDao.getTo()); email.send(); } catch (Exception e) { logger.error("send email", e); throw e; } }
From source file:com.enseval.ttss.util.MailNotif.java
public void emailGiroTolak(Giro gironya, String namaCustomer, String customerID) { String port = (Executions.getCurrent().getServerPort() == 80) ? "" : (":" + Executions.getCurrent().getServerPort()); String url = Executions.getCurrent().getScheme() + "://" + Executions.getCurrent().getServerName() + port + Executions.getCurrent().getContextPath() + "/info_giro.zul"; String msg = "<html>" + "<head>" + "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />" + "<title>Untitled Document</title>" + "<style type=\"text/css\">" + "p {" + "font-family: \"Courier New\", Courier, monospace;" + "font-size: 12px;" + "}" + "</style>" + "</head>" + "<p>Yth, </p>" + "<p>Berikut kami informasikan customer/outlet baru ditambahkan dalam daftar giro tolak;</p> " + "<br/>" + "<p><pre>" + "Customer ID : " + customerID + "<br/>" + "Nama Customer : " + namaCustomer + "<br/>" + "Nomor Giro : " + gironya.getNomorGiro() + "<br/>" + "Nilai : " + Rupiah.format(gironya.getNilai()) + "<br/>" + "Bank : " + gironya.getBank() + "<br/>" + "Keterangan : " + gironya.getKeterangan() + "" + "<pre>" + "</p>" + "<br/>" + "<br/>" + "<br/>" + "<p>Outlet akan di hold sementara oleh bagian Data Proses, selama di hold outlet tidak bisa melakukan order</p>" + "<br/>" + "<br/>" + "<p><i>Note : " + "<br>" + "Info giro " + url + "<br/>" + "Ini adalah email otomatis, mohon tidak membalas email ini !</i></p>" + "</html>"; try {/* ww w . java 2 s . c o m*/ HtmlEmail mail = new HtmlEmail(); mail.setHostName(Util.setting("smtp_host")); mail.setSmtpPort(Integer.parseInt(Util.setting("smtp_port"))); mail.setAuthenticator((Authenticator) new DefaultAuthenticator(Util.setting("smtp_username"), Util.setting("smtp_password"))); mail.setFrom(Util.setting("email_from")); for (String s : Util.setting("email_to").split(",")) { mail.addTo(s.trim()); } mail.setSubject("[INFO GIRO TOLAK] - Nomor Giro : " + gironya.getNomorGiro() + " , Customer : " + namaCustomer + " (" + customerID + ")"); mail.setHtmlMsg(msg); mail.send(); } catch (EmailException ex) { Logger.getLogger(Util.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.enseval.ttss.util.MailNotif.java
public void emailTolakUpdate(Giro gironya) { String port = (Executions.getCurrent().getServerPort() == 80) ? "" : (":" + Executions.getCurrent().getServerPort()); String url = Executions.getCurrent().getScheme() + "://" + Executions.getCurrent().getServerName() + port + Executions.getCurrent().getContextPath() + "/info_giro.zul"; String msg = "<html>" + "<head>" + "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />" + "<title>Untitled Document</title>" + "<style type=\"text/css\">" + "p {" + "font-family: \"Courier New\", Courier, monospace;" + "font-size: 12px;" + "}" + "</style>" + "</head>" + "<p>Yth, </p>" + "<p>Berikut kami informasikan giro tolakan berikut sudah di proses kliring ulang;</p> " + "<br/>" + "<p><pre>" + "Customer ID : " + gironya.getCustomer().getId() + "<br/>" + "Nama Customer : " + gironya.getCustomer().getNama() + "<br/>" + "Nomor Giro : " + gironya.getNomorGiro() + "<br/>" + "Nilai : " + Rupiah.format(gironya.getNilai()) + "<br/>" + "Bank : " + gironya.getBank() + "<br/>" + "Tgl Kliring : " + gironya.getTglKliring() + "<br/>" + "Keterangan : " + gironya.getKeterangan() + "" + "<pre>" + "</p>" + "<br/>" + "<br/>" + "<br/>" + "<p>Jika tidak ada tolakan, account shipto customer akan segera diaktifkan oleh bagian Data Proses.</p>" + "<br/>" + "<br/>" + "<p><i>Note : " + "<br>" + "Info giro " + url + "<br/>" + "Ini adalah email otomatis, mohon tidak membalas email ini !</i></p>" + "</html>"; try {/*from w w w .jav a2 s. c o m*/ HtmlEmail mail = new HtmlEmail(); mail.setHostName(Util.setting("smtp_host")); mail.setSmtpPort(Integer.parseInt(Util.setting("smtp_port"))); mail.setAuthenticator((Authenticator) new DefaultAuthenticator(Util.setting("smtp_username"), Util.setting("smtp_password"))); mail.setFrom(Util.setting("email_from")); for (String s : Util.setting("email_to").split(",")) { mail.addTo(s.trim()); } mail.setSubject("[INFO GIRO TOLAK - Update] - Nomor Giro : " + gironya.getNomorGiro() + " , Customer : " + gironya.getCustomer().getNama() + " (" + gironya.getCustomer().getId() + ")"); mail.setHtmlMsg(msg); mail.send(); } catch (EmailException ex) { Logger.getLogger(Util.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:enviocorreo.EnviadorCorreo.java
/** * Enva un correo electrnico. Utiliza la biblioteca Apache Commons Email, * accesible va <a href="https://commons.apache.org/proper/commons-email/">https://commons.apache.org/proper/commons-email/</a> * * @param destinatario// w w w . ja va 2 s .com * @param asunto * @param mensaje * @return */ public boolean enviarCorreoE(String destinatario, String asunto, String mensaje) { boolean resultado = false; HtmlEmail email = new HtmlEmail(); email.setHostName(host); email.setSmtpPort(puerto); email.setAuthenticator(new DefaultAuthenticator(usuario, password)); if (isGmail) { email.setSSLOnConnect(true); } else { email.setStartTLSEnabled(true); } try { email.setFrom(usuario + "<dominio del correo>"); email.setSubject(asunto); email.setHtmlMsg(mensaje); email.addTo(destinatario); email.send(); resultado = true; } catch (EmailException eme) { mensaje = "Ocurri un error al hacer el envo de correo."; mensajeError = eme.toString(); } return resultado; }
From source file:br.com.itfox.beans.SendHtmlFormatedEmail.java
public void sendingHtml() { try {/*from w w w. j av a 2 s .c om*/ // Create the email message HtmlEmail email = new HtmlEmail(); email.setHostName("mail.congressotrt15.com.br"); email.setSmtpPort(587); email.setAuthenticator(new DefaultAuthenticator("congresso@congressotrt15.com.br", "admtrt15xx")); email.setSSLOnConnect(false); //email.setTLS(true); email.setFrom("congresso@congressotrt15.com.br"); email.setSubject("TestMail"); email.addTo("belchiorpalma@gmail.com", "Belchior Palma"); //email.setFrom("belchiorpalma@me.com", "Me"); email.setSubject("Test email with inline image"); email.setSubject(MimeUtility.encodeText("Test email with inline image", "UTF-8", "B")); // embed the image and get the content id URL url = new URL("http://www.apache.org/images/asf_logo_wide.gif"); String cid = email.embed(url, "Apache logo"); // set the html message email.setHtmlMsg("<html>The apache logo - <img src=\"cid:" + cid + "\"></html>"); // set the alternative message email.setTextMsg("Your email client does not support HTML messages"); // send the email email.send(); } catch (EmailException ex) { Logger.getLogger(SendHtmlFormatedEmail.class.getName()).log(Level.SEVERE, null, ex); } catch (UnsupportedEncodingException ex) { Logger.getLogger(SendHtmlFormatedEmail.class.getName()).log(Level.SEVERE, null, ex); } catch (MalformedURLException ex) { Logger.getLogger(SendHtmlFormatedEmail.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:dk.dma.ais.abnormal.analyzer.reports.ReportMailer.java
/** * Send email with subject and message body. * @param subject the email subject.// w w w . j av a2s. c o m * @param body the email body. */ public void send(String subject, String body) { try { HtmlEmail email = new HtmlEmail(); email.setHostName(configuration.getString(CONFKEY_REPORTS_MAILER_SMTP_HOST, "localhost")); email.setSmtpPort(configuration.getInt(CONFKEY_REPORTS_MAILER_SMTP_PORT, 465)); email.setAuthenticator( new DefaultAuthenticator(configuration.getString(CONFKEY_REPORTS_MAILER_SMTP_USER, "anonymous"), configuration.getString(CONFKEY_REPORTS_MAILER_SMTP_PASS, "guest"))); email.setStartTLSEnabled(false); email.setSSLOnConnect(configuration.getBoolean(CONFKEY_REPORTS_MAILER_SMTP_SSL, true)); email.setFrom(configuration.getString(CONFKEY_REPORTS_MAILER_SMTP_FROM, "")); email.setSubject(subject); email.setHtmlMsg(body); String[] receivers = configuration.getStringArray(CONFKEY_REPORTS_MAILER_SMTP_TO); for (String receiver : receivers) { email.addTo(receiver); } email.send(); LOG.info("Report sent with email to " + email.getToAddresses().toString() + " (\"" + subject + "\")"); } catch (EmailException e) { LOG.error(e.getMessage(), e); } }
From source file:br.com.itfox.beans.SendHtmlFormatedEmail.java
public void sendingHtml(String destinatario, String nome, String assunto, URL linkBoleto) { try {//from ww w . ja va 2s .c o m // Create the email message HtmlEmail email = new HtmlEmail(); email.setHostName("mail.congressotrt15.com.br"); email.setSmtpPort(587); email.setAuthenticator(new DefaultAuthenticator("congresso@congressotrt15.com.br", "admtrt15xx")); email.setSSLOnConnect(false); //email.setTLS(true); email.setFrom("congresso@congressotrt15.com.br"); email.setSubject("TestMail"); email.addTo(destinatario, nome); //email.setFrom("belchiorpalma@me.com", "Me"); email.setSubject(assunto); email.setSubject(MimeUtility.encodeText(assunto, "UTF-8", "B")); // embed the image and get the content id URL url = linkBoleto;//new URL(linkBoleto); String cid = email.embed(url, new BusinessDelegate().getMensagem(new BigDecimal(61)).getAssunto()); // localizando a mensagem //Mensagem msg = new Mensagem(); //msg = new BusinessDelegate().getMensagem(mensagemId); // set the html message //email.setHtmlMsg("<html>The apache logo - <img src=\"cid:"+cid+"\"></html>"); String body = ""; body += this.htmlHead; body += (this.bodyProfissional); body += ("Faça Download do Boleto para pagamento: - <a href=" + url + " target=\"_blank\">Clique Aqui para baixar o Boleto.</a>"); body += "<img src=\"cid:" + cid + "\">"; body += ("</body></html>"); //email.setContent(body,CONTENT_TYPE); email.setHtmlMsg(body); //email.setHeaders(null); //email.setHtmlMsg(body); // set the alternative message email.setTextMsg("Your email client does not support HTML messages"); // send the email email.send(); } catch (EmailException ex) { Logger.getLogger(SendHtmlFormatedEmail.class.getName()).log(Level.SEVERE, null, ex); } catch (UnsupportedEncodingException ex) { Logger.getLogger(SendHtmlFormatedEmail.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:br.com.itfox.beans.SendHtmlFormatedEmail.java
/** * * @param destinatario/* w ww . j a v a 2 s. c o m*/ * @param nome * @param assunto * @throws IOException */ public void sendingHtml(String destinatario, String nome, String assunto, int tipoId) throws IOException { try { // Create the email message HtmlEmail email = new HtmlEmail(); email.setHostName("mail.congressotrt15.com.br"); email.setSmtpPort(587); email.setAuthenticator(new DefaultAuthenticator("congresso@congressotrt15.com.br", "admtrt15xx")); email.setSSLOnConnect(false); //email.setTLS(true); email.setFrom("congresso@congressotrt15.com.br"); //email.setSubject("TestMail"); email.addTo(destinatario, nome); //email.setFrom("belchiorpalma@me.com", "Me"); email.setSubject(assunto); email.setSubject(MimeUtility.encodeText(assunto, "UTF-8", "B")); // embed the image and get the content id // URL url = linkBoleto;//new URL(linkBoleto); //String cid = email.embed(url, "Congresso TRT 15"); // set the html message //email.setHtmlMsg("<html>The apache logo - <img src=\"cid:"+cid+"\"></html>"); String body = ""; body += this.htmlHead; if (tipoId == 1) { body += (this.bodyProfissional); } else if (tipoId == 2) { body += (this.bodyServidor); } else if (tipoId == 3) { body += (this.bodyMagistrado); } else if (tipoId == 4) { body += (this.bodyEstudante); } else { body += "Congresso TRT"; } // body+=("Faa Download do Boleto para pagamento: - <a href="+url+" target=\"_blank\">Clique Aqui para baixar o Boleto.</a>"); //body+="<img src=\"cid:"+cid+"\">"; body += ("</body></html>"); //email.setContent(body,CONTENT_TYPE); email.setHtmlMsg(body); //email.setHeaders(CONTENT_TYPE); //email.setHtmlMsg(body); // set the alternative message email.setTextMsg("Your email client does not support HTML messages"); // send the email email.send(); } catch (EmailException ex) { // utils.Logger.getLogger("Erro ao enviar Email. "+tipoId+" - "+ex.toString(),tipoId); // utils.Logger.getLoggerPessoaFisica("Erro ao enviar email - sending html:"+ex.getMessage()); } }