List of usage examples for org.apache.commons.mail HtmlEmail addTo
public Email addTo(final String email) throws EmailException
From source file:com.actionbazaar.email.EmailService.java
/** * Sends out an email/* w w w. j a v a2s . c o m*/ * @param message - message to be sent */ public void onMessage(Message message) { try { EmailRequest emailRequest = (EmailRequest) ((ObjectMessage) message).getObject(); Query query = entityManager.createQuery("select e from Email e where e.action = ?1"); query.setParameter(1, emailRequest.getAction()); List results = query.getResultList(); if (results.size() != 1) { logger.severe("A total of " + results.size() + " email templates were returned for action " + emailRequest.getAction()); return; } System.out.println("--> Sending email."); Email emailInfo = (Email) results.get(0); logger.info("Speaker Directory: " + attachmentDirectory); HtmlEmail email = new HtmlEmail(); email.setMailSession(mailSession); email.setTextMsg("Hello World!"); // email.setSubject(template.getSubject()); email.addTo("rcuprak@mac.com"); email.setFrom("java@ctjava.org"); // email.send(); /* emailTemplate.process(emailRecipient.getReplacementTokens()); for (Map.Entry<String,File> entry : emailTemplate.getCidMappings().entrySet()) { email.embed(entry.getValue(),entry.getKey()); } email.setHtmlMsg(emailTemplate.getPatchedEmail()); */ } catch (Throwable t) { t.printStackTrace(); //context.setRollbackOnly(); } }
From source file:com.itcs.commons.email.impl.RunnableSendHTMLEmail.java
public void run() { Logger.getLogger(RunnableSendHTMLEmail.class.getName()).log(Level.INFO, "executing Asynchronous task RunnableSendHTMLEmail"); try {/* ww w.ja v a2s. com*/ HtmlEmail email = new HtmlEmail(); email.setCharset("utf-8"); email.setMailSession(getSession()); for (String dir : to) { email.addTo(dir); } if (cc != null) { for (String ccEmail : cc) { email.addCc(ccEmail); } } if (cco != null) { for (String ccoEmail : cco) { email.addBcc(ccoEmail); } } email.setSubject(subject); // set the html message email.setHtmlMsg(body); email.setFrom(getSession().getProperties().getProperty(Email.MAIL_SMTP_FROM, Email.MAIL_SMTP_USER), getSession().getProperties().getProperty(Email.MAIL_SMTP_FROMNAME, Email.MAIL_SMTP_USER)); // set the alternative message email.setTextMsg("Si ve este mensaje, significa que su cliente de correo no permite mensajes HTML."); // send the email if (attachments != null) { addAttachments(email, attachments); } email.send(); Logger.getLogger(RunnableSendHTMLEmail.class.getName()).log(Level.INFO, "Email sent successfully to:{0} cc:{1} bcc:{2}", new Object[] { Arrays.toString(to), Arrays.toString(cc), Arrays.toString(cco) }); } catch (EmailException e) { Logger.getLogger(RunnableSendHTMLEmail.class.getName()).log(Level.SEVERE, "EmailException Error sending email... with properties:\n" + session.getProperties(), e); } }
From source file:br.com.atmatech.sac.controller.Email.java
public void emaiMassa(String smtp, String user, String password, Integer porta, Boolean ssl, Boolean tls, List<PessoaBeans> emailto, String emailfrom, String conteudo, String assunto) throws EmailException, MalformedURLException { HtmlEmail email = new HtmlEmail(); email.setHostName(smtp); // o servidor SMTP para envio do e-mail Integer indice2 = 0;/*from w w w. j a va2s .com*/ Integer j = 0; for (int i = 0; (i < emailto.size()) && (i < 45); i++) { email.addTo(emailto.get(i).getEmail());//destinatario indice2 = i; } while (j <= indice2) { emailto.remove(0); j++; } conteudo = conteudo.replaceAll("\n", "<p>"); email.setFrom(emailfrom); // remetente //email.addCc(emailfrom); email.setSubject(assunto); // configura a mensagem para o formato HTML email.setHtmlMsg("<html><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">" + conteudo + "</html>"); email.setAuthentication(user, password); email.setSmtpPort(porta); email.setSSL(ssl); email.setTLS(tls); email.send(); if (emailto != null) { if (emailto.size() > 1) { emaiMassa(smtp, user, password, porta, ssl, tls, emailto, emailfrom, conteudo, assunto); } } }
From source file:ca.ualberta.physics.cssdp.auth.service.EmailServiceImpl.java
public void sendEmail(String from, String to, String subject, String body) { try {//from ww w . ja v a 2 s . c o m 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:io.marto.aem.utils.email.FreemarkerTemplatedMailer.java
private HtmlEmail constructEmail(final String[] recipients, String sender, final String subject, String template, Object model) throws EmailException { final HtmlEmail email = new HtmlEmail(); email.setMsg(renderBody(template, model)); if (subject != null) { email.setSubject(subject);/*from ww w . j av a2s .com*/ } if (sender != null) { email.setFrom(sender); } for (String recipient : recipients) { email.addTo(recipient); } return email; }
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); sendemail.setFrom("jinuk@ideaconcert.com", ""); sendemail.setSubject("? ?? ?."); sendemail.setAuthentication("jinuk@ideaconcert.com", "tpxmapsb1"); sendemail.setSmtpPort(465);//from w w w . ja va 2 s . c o m 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); sendemail.setFrom("jinuk@ideaconcert.com", ""); sendemail.setSubject("? ."); sendemail.setAuthentication("jinuk@ideaconcert.com", "tpxmapsb1"); sendemail.setSmtpPort(465);//from ww w . j a va2s . c om 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:libs.BuildMail.java
private void sendMail(String address, String subject, String msg) { try {/*from w w w .j av a 2s.co 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: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 .j a 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:com.fatecib.projetoemail.servlets.DAO.Enviaremail2.java
private void enviar(Email em, ConfiguracaoSQL conf, String destinatario) throws EmailException { try {/*from w w w . ja v a 2 s. co m*/ 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; } }