List of usage examples for org.apache.commons.mail HtmlEmail setSSLOnConnect
public Email setSSLOnConnect(final boolean ssl)
From source file:com.smi.travel.controller.mail.SendMail.java
public static void main(String args[]) throws Exception { EmailAttachment attachment = new EmailAttachment(); HtmlEmail email = new HtmlEmail(); try {// w w w. j a v a2 s . com // attachment.setPath("C:\\Users\\chonnasith\\Desktop\\test.txt"); // attachment.setDescription("file attachment"); // attachment.setName("test.txt"); // email.attach(attachment); email.setHostName(hostname); email.setSmtpPort(port); email.setAuthentication(username, password); email.setSSLOnConnect(true); // email.setStartTLSEnabled(true); // email.setStartTLSRequired(true); email.setFrom(username); email.setSubject(subject); email.addTo(addto); email.setHtmlMsg(message); email.send(); System.out.println("Email Send"); System.out.println("Port : " + email.getSmtpPort()); } catch (EmailException ex) { System.out.println("Email Exception"); System.out.println("Port : " + email.getSmtpPort()); ex.printStackTrace(); } // InetAddress host = InetAddress.getByName("mail.foobar.com"); // System.out.println("host.isReachable(1000) = " + host.isReachable(1000)); // int port = 587; // String host = "smtp.gmail.com"; // String user = "username@gmail.com"; // String pwd = "email password"; // // try { // Properties props = new Properties(); // // required for gmail // props.put("mail.smtp.starttls.enable","true"); // props.put("mail.smtp.auth", "true"); // // or use getDefaultInstance instance if desired... // Session session = Session.getInstance(props, null); // Transport transport = session.getTransport("smtp"); // transport.connect(host, port, user, pwd); // transport.close(); // System.out.println("success"); // } // catch(AuthenticationFailedException e) { // System.out.println("AuthenticationFailedException - for authentication failures"); // e.printStackTrace(); // } // catch(MessagingException e) { // System.out.println("for other failures"); // e.printStackTrace(); // } // Properties prop=new Properties(); // prop.put("mail.smtp.auth", "true"); // prop.put("mail.smtp.host", "smtp.gmail.com"); // prop.put("mail.smtp.port", "587"); // prop.put("mail.smtp.starttls.enable", "true"); // // Session session = Session.getDefaultInstance(prop, // new javax.mail.Authenticator() { // protected PasswordAuthentication getPasswordAuthentication() { // return new PasswordAuthentication("finance@wendytour", "wendytr"); // } // }); // // try { // String body="Dear Renish Khunt Welcome"; // String htmlBody = "<strong>This is an HTML Message</strong>"; // String textBody = "This is a Text Message."; // Message message = new MimeMessage(session); // message.setFrom(new InternetAddress(username)); // message.setRecipients(Message.RecipientType.TO,InternetAddress.parse(addto)); // message.setSubject("Testing Subject"); // 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); // message.setText(htmlBody); // message.setContent(textBody, "text/html"); // Transport.send(message); // // System.out.println("Done"); // // } catch (MessagingException e) { // e.printStackTrace(); // } // final String fromEmail = "finance@wendytour"; //requires valid gmail id // final String password = "wendytr"; // correct password for gmail id // final String toEmail = "wee.chonnasith@gmail.com"; // can be any email id // // System.out.println("TLSEmail Start"); // Properties props = new Properties(); // props.put("mail.smtp.host", ""); //SMTP Host // props.put("mail.smtp.port", "587"); //TLS Port // props.put("mail.smtp.auth", "true"); //enable authentication // props.put("mail.smtp.starttls.enable", "true"); //enable STARTTLS // // //create Authenticator object to pass in Session.getInstance argument // Authenticator auth = new Authenticator() { // //override the getPasswordAuthentication method // protected PasswordAuthentication getPasswordAuthentication() { // return new PasswordAuthentication(fromEmail, password); // } // }; // Session session = Session.getInstance(props, auth); // // EmailUtil.sendEmail(session, toEmail,"TLSEmail Testing Subject", "TLSEmail Testing Body"); // }
From source file:br.com.rp.services.EmailService.java
private static HtmlEmail configurarEmailPadrao() throws EmailException { HtmlEmail email = new HtmlEmail(); email.setHostName("smtp.gmail.com"); email.setSmtpPort(465);//w ww . j a v a 2 s. com email.setAuthentication(ENDERECO_EMAIL, SENHA); email.setSSLOnConnect(true); email.setCharset(StandardCharsets.UTF_8.toString()); email.setFrom(ENDERECO_EMAIL, "Sistema VBANK"); return email; }
From source file:function.Email.java
public static void sendOrderEmail(String OrderID, String CustomnerEmail) { try {/*from w w w. jav a 2s . 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(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 av a2s. c om 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:br.com.dedoduro.util.EnviarEmail.java
/** * Enviar o email para a lista de usarios especificados * @param emails/* w w w. j a v a 2 s . co 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 w ww . ja va2 s .c o m*/ * @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:email.cadastro.EmailCadastro.java
public boolean EnviarCodConfirmacao(String codigo, String emailCadastro) { HtmlEmail email = new HtmlEmail(); email.setSSLOnConnect(true); email.setHostName("smtp.gmail.com"); //email.setSslSmtpPort("465"); email.setAuthenticator(new DefaultAuthenticator("contatogamesapp@gmail.com", "gamesifsul")); try {/*www .j a va2 s .c o m*/ 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.cerebro.gorgone.commons.SendConfEmail.java
public SendConfEmail(String address, String confCode) { logger.info("Invio della mail di conferma"); // Leggo i parametri di invio Properties props = new Properties(); InputStream config = VaadinServlet.getCurrent().getServletContext() .getResourceAsStream("/WEB-INF/config.properties"); if (config != null) { try {/*from w w w .ja v a 2 s . c o m*/ logger.info("Carico il file .properties"); props.load(config); } catch (Exception ex) { logger.error("Errore nel caricamento del file .properties: " + ex.getMessage()); } } smtp_host = props.getProperty(ConfigProperties.SMTP_HOST); smtp_port = Integer.getInteger(props.getProperty(ConfigProperties.SMTP_PORT)); smtp_user = props.getProperty(ConfigProperties.SMTP_USER); smtp_pwd = props.getProperty(ConfigProperties.SMTP_PWD); smtp_security = Boolean.parseBoolean(ConfigProperties.SMTP_SECURITY); // Creo la mail HtmlEmail email = new HtmlEmail(); try { email.setHostName(smtp_host); email.setSmtpPort(smtp_port); email.setSSLOnConnect(smtp_security); email.setAuthentication(smtp_user, smtp_pwd); email.setFrom("gioco@gioco.com", "Gioco"); email.setSubject("Conferma il tuo indirizzo email " + confCode); email.addTo(address); email.setMsg("Messaggio della mail"); email.send(); logger.info("Email inviata"); } catch (EmailException ex) { logger.error("Errore nell'invio della mail"); logger.error(ex.getMessage()); } }
From source file:be.thomasmore.controller.EmailController.java
public String sendEmail() throws EmailException { Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext() .getRequestParameterMap();/* w ww. ja 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; }
From source file:io.mif.labanorodraugai.services.EmailService.java
private void setUpHtmlEmail(HtmlEmail email) throws EmailException { email.setHostName("smtp.googlemail.com"); email.setSmtpPort(465);/* w ww . jav a 2s.c o m*/ email.setAuthenticator(new DefaultAuthenticator("labanorodraugaibendrija@gmail.com", "labanoro123")); email.setSSLOnConnect(true); email.setCharset("UTF-8"); email.setFrom("labanorodraugaibendrija@gmail.com", "Labanoro draugai"); }