List of usage examples for org.apache.commons.mail HtmlEmail HtmlEmail
HtmlEmail
From source file:com.vicky.common.utils.sendemail.SendEmailImpl.java
@Override public void send(Mail mail) throws Exception { try {// w w w .ja va 2 s . c o m HtmlEmail htmlEmail = new HtmlEmail(); htmlEmail.setHostName(mail.getHost()); htmlEmail.setCharset(Mail.ENCODEING); htmlEmail.addTo(mail.getReceiverEmailAddress()); htmlEmail.setFrom(mail.getSenderEmailAddress(), mail.getName()); htmlEmail.setAuthentication(mail.getSenderUsername(), mail.getSenderPassword()); htmlEmail.setSubject(mail.getSubject()); htmlEmail.setMsg(mail.getMessage()); for (MailAttach mailFile : mail.getMailAttachs()) { EmailAttachment attachment = new EmailAttachment();// attachment.setPath(mailFile.getFilePath());//? //attachment.setURL(new URL("http://www.baidu.com/moumou"));//? attachment.setDisposition(EmailAttachment.ATTACHMENT); attachment.setName(MimeUtility.encodeText(mailFile.getFileName()));//?? htmlEmail.attach(attachment);//,? } htmlEmail.send(); } catch (Exception exception) { exception.printStackTrace(); this.logger.error("toString" + exception.toString()); this.logger.error("getMessage" + exception.getMessage()); this.logger.error("exception", exception); throw new StatusMsgException( "??,??,?,?V!"); } }
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 a v 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:io.mif.labanorodraugai.services.EmailService.java
public void SendInvitationEmail(Account sender, String toEmail) throws EmailException, MalformedURLException { //ImageHtmlEmail email = new ImageHtmlEmail(); HtmlEmail email = new HtmlEmail(); setUpHtmlEmail(email);//from ww w. j ava 2s . com email.addTo(toEmail); email.setSubject("Labanoro draug kvietimas"); StringBuilder msg = new StringBuilder(); //msg.append("<div><img src=\"" + baseUrl + "/images/lab anorodraugai.JPG\"></div>"); msg.append("<h4>Sveiki,</h4>"); msg.append("<p>" + sender.getName() + " " + sender.getLastname() + " kvie?ia Jus tapti bendrijos Labanoro draugai nariu!</p>"); msg.append("<p>T padaryti galite usiregistrav "); msg.append("<a href=" + "\"http://localhost:8080/LabanoroDraugai/registration/registration.html\">"); msg.append("?ia</a></p>"); email.setContent(msg.toString(), EmailConstants.TEXT_HTML); email.send(); }
From source file:function.Email.java
public static void sendOrderEmail(String OrderID, String CustomnerEmail) { try {/*from www . j a v a2s. 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(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:com.fatecib.projetoemail.servlets.DAO.Enviaremail2.java
private void enviar(Email em, ConfiguracaoSQL conf, String destinatario) throws EmailException { try {/*from w ww. j a v a2 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; } }
From source file:de.maklerpoint.office.Marketing.Tools.SendNewsletter.java
/** * * @param nl//w w w.ja va 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:br.com.estube.portalcommunication.util.Email.java
public Email() { email = new HtmlEmail(); configure(); }
From source file:br.com.atmatech.sac.controller.Email.java
public void emailAtendimento(String smtp, String user, String password, Integer porta, Boolean ssl, Boolean tls, String emailto, String emailfrom, String solicitante, String nchamado, String razao, String data, String solicitacao, String realizacao, String tecnico, String imagem) throws EmailException, MalformedURLException { System.err.println(smtp + ":\n" + user + ":\n" + password + ":\n" + porta + ":\n" + ssl + ":\n" + tls + ":\n" + emailto + ":\n" + emailfrom + ":\n" + solicitante + ":\n" + nchamado + ":\n" + razao + ":\n" + data + ":\n" + solicitacao + ":\n" + realizacao + ":\n" + tecnico + ":\n" + imagem); HtmlEmail email = new HtmlEmail(); // SimpleEmail email = new SimpleEmail(); email.setHostName(smtp); // o servidor SMTP para envio do e-mail email.addTo(emailto); //destinatrio email.setFrom(emailfrom); // remetente email.setSubject("Aviso de Atendimento - Suporte"); // configura a mensagem para o formato HTML email.setHtmlMsg(/*from w ww.j a va 2 s . c o m*/ "<html><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">Prezado(a)Senhor(a).<br>" + "<b>" + solicitante + "</b><p>" + "Informamos que o protocolo nmero
<b> " + nchamado + "</b> foi finalizado por nossa Central de Suporte.<p>" + "Cliente<br>" + "" + razao + "<p>" + "Data<br>" + "" + data + "<p>" + "Descrio do Problema<br>" + "" + solicitacao + "<p>" + "Soluo<br>" + "" + realizacao + "<p>" + "Atendente<br>" + "" + tecnico + "<p>" + "<b>Atenciosamente</b> Suporte Atmatech<p><p>" + imagem + " </html>"); //email.setMsg("Teste"); email.setAuthentication(user, password); email.setSmtpPort(porta); email.setSSL(ssl); email.setTLS(tls); email.send(); }
From source file:org.meruvian.yama.webapi.config.EmailConfig.java
@Bean @Scope("prototype") public HtmlEmail email() throws EmailException { HtmlEmail email = new HtmlEmail(); email.setHostName(props.getProperty("host")); email.setSmtpPort(props.getProperty("port", Integer.class, 0)); email.setAuthentication(props.getProperty("username"), props.getProperty("password")); email.setFrom(props.getProperty("from_email"), props.getProperty("from_alias")); email.setSSLOnConnect(props.getProperty("ssl", Boolean.class, false)); email.setStartTLSEnabled(props.getProperty("tls", Boolean.class, false)); return email; }
From source file:actors.ValidationEmailSender.java
@Override public void onReceive(Object object) { if (!(object instanceof Email)) { return;//from w ww. j a va2 s .com } Email email = (Email) object; final HtmlEmail htmlEmail = new HtmlEmail(); try { htmlEmail.setFrom(Config.getEmailFromSmtp(), utils.Config.getSiteName()); htmlEmail.addTo(email.email, email.user.name); htmlEmail.setSubject(Messages.get("emails.validation.email.title", utils.Config.getSiteName())); htmlEmail.setHtmlMsg(getMessage(email.confirmUrl)); htmlEmail.setCharset("utf-8"); Mailer.send(htmlEmail); String escapedTitle = htmlEmail.getSubject().replace("\"", "\\\""); String logEntry = String.format("\"%s\" %s", escapedTitle, htmlEmail.getToAddresses()); play.Logger.of("mail").info(logEntry); } catch (Exception e) { Logger.warn("Failed to send a notification: " + email + "\n" + ExceptionUtils.getStackTrace(e)); } }