Package org.apache.commons.mail

Examples of org.apache.commons.mail.Email


   * @param to
   * @param message
   * @throws Exception
   */
  private static void sendEmail(String mailserver, int port, String from, String to, String message, String username, String password) throws EmailException
    Email email = new SimpleEmail();
    email.setDebug(false); // true if you want to debug
        email.setHostName(mailserver);
        if (username != null) {
      email.setAuthentication(username, password);
          email.getMailSession().getProperties().put(
             "mail.smtp.starttls.enable", "true");
    }
        email.setFrom(from, "Wookie Server");
        email.setSubject("Wookie API Key");
        email.setMsg(message);
        email.addTo(to);
        email.send();
  }
View Full Code Here


  @Override
  public Map<Email, Future<Void>> deliverPostponedMails() {
    Map<Email, Future<Void>> deliveries = new HashMap<Email, Future<Void>>();
    LOGGER.debug("Delivering all {} postponed emails", this.mailQueue.size());
    while (!this.mailQueue.isEmpty()) {
      Email nextMail = this.mailQueue.poll();
      Future<Void> sendingResult = this.asyncSend(nextMail);
      deliveries.put(nextMail, sendingResult);
    }
    return deliveries;
  }
View Full Code Here

   * @param to
   * @param message
   * @throws Exception
   */
  private static void sendEmail(String mailserver, int port, String from, String to, String message, String username, String password) throws EmailException
    Email email = new SimpleEmail();
    email.setDebug(false); // true if you want to debug
        email.setHostName(mailserver);
        if (username != null) {
      email.setAuthentication(username, password);
          email.getMailSession().getProperties().put(
             "mail.smtp.starttls.enable", "true");
    }
        email.setFrom(from, "Wookie Server");
        email.setSubject("Wookie API Key");
        email.setMsg(message);
        email.addTo(to);
        email.send();
  }
View Full Code Here

     * @throws EmailException
     */
    public static Boolean sendMail(List<String> toAddress, String subject,
            String message, SettingManager settings) {
        // Create data information to compose the mail
        Email email = new SimpleEmail();
        configureBasics(settings, email);

        email.setSubject(subject);
        try {
            email.setMsg(message);
        } catch (EmailException e1) {
            e1.printStackTrace();
            return false;
        }
        email.setSSL(true);

        // send to all mails extracted from settings
        for (String add : toAddress) {
            try {
                email.addBcc(add);
            } catch (EmailException e) {
                e.printStackTrace();
            }
        }

View Full Code Here

     */
    public static Boolean sendMail(List<String> toAddress, String subject,
            String message, SettingManager settings, String replyTo,
            String replyToDesc) {
        // Create data information to compose the mail
        Email email = new SimpleEmail();
        configureBasics(settings, email);

        List<InternetAddress> addressColl = new ArrayList<InternetAddress>();
        try {
            addressColl.add(new InternetAddress(replyTo, replyToDesc));
            email.setReplyTo(addressColl);
        } catch (UnsupportedEncodingException e2) {
            e2.printStackTrace();
            return false;
        } catch (EmailException e) {
            e.printStackTrace();
            return false;
        }

        email.setSubject(subject);
        try {
            email.setMsg(message);
        } catch (EmailException e1) {
            e1.printStackTrace();
            return false;
        }
        email.setSSL(true);

        // send to all mails extracted from settings
        for (String add : toAddress) {
            try {
                email.addBcc(add);
            } catch (EmailException e) {
                e.printStackTrace();
            }
        }

View Full Code Here

     */
    public static Boolean sendMail(List<String> toAddress, String hostName,
            Integer smtpPort, String from, String username, String password,
            String subject, String message) {

        Email email = new SimpleEmail();
        configureBasics(hostName, smtpPort, from, username, password, email, false);

        email.setSubject(subject);
        try {
            email.setMsg(message);
        } catch (EmailException e1) {
            e1.printStackTrace();
            return false;
        }
        email.setSSL(true);

        // send to all mails extracted from settings
        for (String add : toAddress) {
            try {
                email.addBcc(add);
            } catch (EmailException e) {
                e.printStackTrace();
                return false;
            }
        }
View Full Code Here

  @Test(expected = MailException.class)
  public void buildMessageWithoutFrom() throws EmailException {
    new PlayBuilder().build();

    Email email = new SimpleEmail();
    email.addTo("from@playframework.org");
    email.setSubject("subject");
    Mail.buildMessage(new SimpleEmail());
  }
View Full Code Here

  @Test(expected = MailException.class)
  public void buildMessageWithoutRecipient() throws EmailException {
    new PlayBuilder().build();

    Email email = new SimpleEmail();
    email.setFrom("from@playframework.org");
    email.setSubject("subject");
    Mail.buildMessage(email);
  }
View Full Code Here

  @Test(expected = MailException.class)
  public void buildMessageWithoutSubject() throws EmailException {
    new PlayBuilder().build();

    Email email = new SimpleEmail();
    email.setFrom("from@playframework.org");
    email.addTo("to@playframework.org");
    Mail.buildMessage(email);
  }
View Full Code Here

  @Test
  public void buildValidMessages() throws EmailException {
    new PlayBuilder().build();

    Email email = new SimpleEmail();
    email.setFrom("from@playframework.org");
    email.addTo("to@playframework.org");
    email.setSubject("subject");
    Mail.buildMessage(email);

    email = new SimpleEmail();
    email.setFrom("from@playframework.org");
    email.addCc("to@playframework.org");
    email.setSubject("subject");
    Mail.buildMessage(email);

    email = new SimpleEmail();
    email.setFrom("from@playframework.org");
    email.addBcc("to@playframework.org");
    email.setSubject("subject");
    Mail.buildMessage(email);
  }
View Full Code Here

TOP

Related Classes of org.apache.commons.mail.Email

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.