Example usage for org.apache.commons.mail HtmlEmail addReplyTo

List of usage examples for org.apache.commons.mail HtmlEmail addReplyTo

Introduction

In this page you can find the example usage for org.apache.commons.mail HtmlEmail addReplyTo.

Prototype

public Email addReplyTo(final String email) throws EmailException 

Source Link

Document

Add a reply to address to the email.

Usage

From source file:com.duroty.utils.mail.MessageUtilities.java

/**
 * DOCUMENT ME!//from www .  j a v a 2  s . co m
 *
 * @param args DOCUMENT ME!
 *
 * @throws UnsupportedEncodingException DOCUMENT ME!
 * @throws EmailException DOCUMENT ME!
 * @throws MessagingException DOCUMENT ME!
 */
public static void main(String[] args) throws UnsupportedEncodingException, EmailException, MessagingException {
    InternetAddress[] aux1 = new InternetAddress[5];
    aux1[0] = new InternetAddress("duroty@iigov.net", "Jordi Marqus");
    aux1[1] = new InternetAddress("duroty@iigov.net", "Jordi Marqus");
    aux1[2] = new InternetAddress("duroty@iigov.net", "Jordi Marqus");
    aux1[3] = new InternetAddress("duroty@iigov.net", "Jordi Marqus");
    aux1[4] = new InternetAddress("duroty@iigov.net", "Jordi Marqus");

    System.out.println(MessageUtilities.decodeAddressesEmail(aux1));

    HtmlEmail email = new HtmlEmail();
    email.setHostName("10.0.0.68");
    email.setFrom("duroty@iigov.net");
    email.addReplyTo("duroty@iigov.net");

    email.addTo("cagao@ii.org");

    email.addCc("raul1@iigov.org");
    email.addCc("raul2@iigov.org");
    email.addCc("raul3@iigov.org");
    email.addCc("raul4@iigov.org");
    email.addCc("raul5@iigov.org");

    email.addBcc("caca1@iigov.org");

    email.setHtmlMsg("<html>la merda fa pudor</html>");

    email.buildMimeMessage();

    MimeMessage mime = email.getMimeMessage();

    System.out.println(MessageUtilities.decodeAddressesEmail(mime.getAllRecipients()));
}

From source file:org.yestech.notify.deliver.HtmlEmailDelivery.java

protected void sendMessage(INotification notification, IRecipient recipient) throws EmailException {
    // Create the email message
    HtmlEmail email = new HtmlEmail();
    enableAuthenticator(email);/* w  w  w . j a  v a2s .c  om*/
    email.setHostName(getEmailHost());
    ISender sender = notification.getSender();
    email.setFrom(sender.getEmailAddress(), sender.getDisplayName());
    if (StringUtils.isNotBlank(sender.getReplyAddress())) {
        email.addReplyTo(sender.getReplyAddress());
    }
    email.setSubject(notification.getMessage().getSubject());
    email.addTo(recipient.getEmailAddress(), recipient.getDisplayName());
    ITemplateLanguage template = notification.getTemplate();
    String appliedMessage = template.apply(notification.getMessage());
    email.setHtmlMsg(appliedMessage);
    email.send();
}