List of usage examples for org.apache.commons.mail HtmlEmail setDebug
public void setDebug(final boolean d)
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"); }/*from w w w . j a v a 2 s . 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:ca.ualberta.physics.cssdp.auth.service.EmailServiceImpl.java
public void sendEmail(String from, String to, String subject, String body) { try {/*from w ww. j ava 2s . c om*/ String host = AuthServer.properties().getString("smtpHost"); int port = AuthServer.properties().getInt("smtpPort"); final String user = AuthServer.properties().getString("smtpUsername"); final String password = AuthServer.properties().getString("smtpPassword"); String systemEmail = AuthServer.properties().getString("systemEmailAddress"); boolean useSSL = AuthServer.properties().getBoolean("smtpUseSSL"); boolean debug = AuthServer.properties().getBoolean("smtpDebug"); HtmlEmail msg = new HtmlEmail(); msg.setHostName(host); msg.setAuthentication(user, password); msg.setSmtpPort(port); msg.setSSL(useSSL); msg.setDebug(debug); msg.setSubject("Password Reset Request"); msg.addTo(to); msg.setFrom(systemEmail); msg.setHtmlMsg(body); msg.send(); } catch (Exception e) { e.printStackTrace(); throw Throwables.propagate(Throwables.getRootCause(e)); } finally { } }
From source file:email.cadastro.EmailCadastro.java
public boolean EnviarCodConfirmacao(String codigo, String emailCadastro) { HtmlEmail email = new HtmlEmail(); email.setSSLOnConnect(true);/*from www . java2 s . c o m*/ 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.aquest.emailmarketing.web.service.SendEmail.java
/** * Send email./*from w ww . j av a 2s. c om*/ * * @param broadcast the broadcast * @param emailConfig the email config * @param emailList the email list * @throws EmailException the email exception * @throws MalformedURLException the malformed url exception * @throws InterruptedException the interrupted exception */ @Async public void sendEmail(Broadcast broadcast, EmailConfig emailConfig, EmailList emailList) throws EmailException, MalformedURLException, InterruptedException { Timestamp curTimestamp = new java.sql.Timestamp(Calendar.getInstance().getTime().getTime()); // email configuration part HtmlEmail email = new HtmlEmail(); email.setSmtpPort(emailConfig.getPort()); email.setHostName(emailConfig.getHostname()); email.setAuthenticator(new DefaultAuthenticator(emailConfig.getUsername(), emailConfig.getPassword())); email.setSSLOnConnect(emailConfig.isSslonconnect()); email.setDebug(emailConfig.isDebug()); email.setFrom(emailConfig.getFrom_address()); //ovde dodati i email from description System.out.println(emailList); HashMap<String, String> variables = processVariableService.ProcessVariable(emailList); for (String keys : variables.keySet()) { System.out.println("key:" + keys + ", value:" + variables.get(keys)); } String processSubject = broadcast.getSubject(); String newHtml = broadcast.getHtmlbody_embed(); String newPlainText = broadcast.getPlaintext(); for (String key : variables.keySet()) { processSubject = processSubject.replace("[" + key + "]", variables.get(key)); System.out.println(key + "-" + variables.get(key)); newHtml = newHtml.replace("[" + key + "]", variables.get(key)); newPlainText = newPlainText.replace("[" + key + "]", variables.get(key)); } System.out.println(processSubject); email.setSubject(processSubject); email.addTo(emailList.getEmail()); String image = embeddedImageService.getEmbeddedImages(broadcast.getBroadcast_id()).getUrl(); List<String> images = Arrays.asList(image.split(";")); for (int j = 0; j < images.size(); j++) { System.out.println(images.get(j)); } for (int i = 0; i < images.size(); i++) { String id = email.embed(images.get(i), "Slika" + i); newHtml = newHtml.replace("[IMAGE:" + i + "]", "cid:" + id); } Config config = configService.getConfig("trackingurl"); //DONE: Create jsp page for tracking server url String serverUrl = config.getValue(); System.out.println(serverUrl); Base64 base64 = new Base64(true); Pattern pattern = Pattern.compile("<%tracking=(.*?)=tracking%>"); Matcher matcher = pattern.matcher(newHtml); while (matcher.find()) { String url = matcher.group(1); System.out.println(url); logger.debug(url); String myEncryptedUrl = new String(base64.encode(url.getBytes())); String oldurl = "<%tracking=" + url + "=tracking%>"; logger.debug(oldurl); System.out.println(oldurl); String newurl = serverUrl + "tracking?id=" + myEncryptedUrl; logger.debug(newurl); System.out.println(newurl); newHtml = newHtml.replace(oldurl, newurl); } // System.out.println(newHtml); email.setHtmlMsg(newHtml); email.setTextMsg(newPlainText); try { System.out.println("A ovo ovde?"); email.send(); emailList.setStatus("SENT"); emailList.setProcess_dttm(curTimestamp); emailListService.SaveOrUpdate(emailList); } catch (Exception e) { logger.error(e); } // time in seconds to wait between 2 mails TimeUnit.SECONDS.sleep(emailConfig.getWait()); }
From source file:com.elexcode.emailservicelibrary.service.EmailSenderServiceImpl.java
@Override public void sendEmail(EmailObject emailObject) throws Exception { HtmlEmail email = new HtmlEmail(); email.setHostName(host);// w ww. j av a 2 s . c om email.setSmtpPort(port); email.setAuthentication(username, password); for (String recipient : emailObject.getRecipients()) { email.addTo(recipient); } email.setFrom(username); email.setSubject(emailObject.getSubject()); if (checkStringNotNullNotEmpty(emailObject.getHtmlMsg())) { email.setHtmlMsg(emailObject.getHtmlMsg()); } else { if (checkStringNotNullNotEmpty(emailObject.getMessage())) { email.setTextMsg(emailObject.getMessage()); } } email.setDebug(false); email.setTLS(true); email.setSSL(true); email.send(); }
From source file:com.ipc.service.SignUpService.java
public String sendhtmlmail(int uid, String key, String email) throws IOException, EmailException { HtmlEmail sendemail = new HtmlEmail(); sendemail.setCharset("euc-kr"); sendemail.setHostName("smtp.worksmobile.com"); sendemail.addTo(email);/*from ww w . j a v a2 s .c o m*/ sendemail.setFrom("jinuk@ideaconcert.com", ""); sendemail.setSubject("? ?? ?."); sendemail.setAuthentication("jinuk@ideaconcert.com", "tpxmapsb1"); sendemail.setSmtpPort(465); sendemail.setSSL(true); //? sendemail.setTLS(true); sendemail.setDebug(true); String htmlmsg = "<html><div style='width:1000px; float:left; border-bottom:2px solid #45d4fe; padding-bottom:5px;box-sizing:border-box;'></div><div style='width:1000px;float:left; box-sizing:border-box; padding:15px;'><h2>? ? ? .</h2><div style='width:100%; float:left; box-sizing:border-box; border:5px solid #f9f9f9; text-align:center; padding:40px 0 40px 0;'><span> ? .</span><br><a href='http://localhost:8088/signup/permit?uid=" + uid + "&key=" + key + "'><button style='width:150px; height:40px; background:none; border:2px solid #45d4fe; font-size:1.1rem; text-decoration: none;font-weight:bold; margin-top:10px;'></button></a></div></div></html>"; System.out.println(htmlmsg); sendemail.setHtmlMsg(htmlmsg); try { sendemail.send(); } catch (Exception e) { System.out.println("NOTOK"); return "NOTOK"; } return "OK"; }
From source file:com.ipc.service.SignUpService.java
public String sendpwmail(int uid, String key, String email) throws IOException, EmailException { System.out.println("Email : " + email); HtmlEmail sendemail = new HtmlEmail(); sendemail.setCharset("euc-kr"); sendemail.setHostName("smtp.worksmobile.com"); sendemail.addTo(email);/*ww w . j a v a 2 s . c o m*/ sendemail.setFrom("jinuk@ideaconcert.com", ""); sendemail.setSubject("? ."); sendemail.setAuthentication("jinuk@ideaconcert.com", "tpxmapsb1"); sendemail.setSmtpPort(465); sendemail.setSSL(true); //? sendemail.setTLS(true); sendemail.setDebug(true); String htmlmsg = "<html><div style='width:1000px; float:left; border-bottom:2px solid #45d4fe; padding-bottom:5px;box-sizing:border-box;'></div><div style='width:1000px;float:left; box-sizing:border-box; padding:15px;'><h2>? .</h2><div style='width:100%; float:left; box-sizing:border-box; border:5px solid #f9f9f9; text-align:center; padding:40px 0 40px 0;'><span> ? <br> .<br>" + key + "</span></html>"; System.out.println(htmlmsg); sendemail.setHtmlMsg(htmlmsg); try { sendemail.send(); } catch (Exception e) { System.out.println("NOTOK"); return "NOTOK"; } return "OK"; }
From source file:org.cerberus.service.email.impl.sendMail.java
public static void sendHtmlMail(String host, int port, String body, String subject, String from, String to, String cc) throws Exception { HtmlEmail email = new HtmlEmail(); email.setSmtpPort(port);//w w w . j av a 2 s. c o m email.setDebug(false); email.setHostName(host); email.setFrom(from); email.setSubject(subject); email.setHtmlMsg(body); String[] destinataire = to.split(";"); for (int i = 0; i < destinataire.length; i++) { String name; String emailaddress; if (destinataire[i].contains("<")) { String[] destinatairedata = destinataire[i].split("<"); name = destinatairedata[0].trim(); emailaddress = destinatairedata[1].replace(">", "").trim(); } else { name = ""; emailaddress = destinataire[i]; } email.addTo(emailaddress, name); } String[] copy = cc.split(";"); for (int i = 0; i < copy.length; i++) { String namecc; String emailaddresscc; if (copy[i].contains("<")) { String[] copydata = copy[i].split("<"); namecc = copydata[0].trim(); emailaddresscc = copydata[1].replace(">", "").trim(); } else { namecc = ""; emailaddresscc = copy[i]; } email.addCc(emailaddresscc, namecc); } email.setTLS(true); email.send(); }