Package org.apache.commons.mail

Examples of org.apache.commons.mail.SimpleEmail


  }

  public void register(ErrorMail errorMail) {
    logger.error(errorMail.getMsg());
    try {
      SimpleEmail email = errorMail.toSimpleMail();
      mailer.send(email);
    } catch (Exception ex) {
      logger.error("Unable to send error by email. THIS IS HARDCORE, nobody will know about this error.", ex);
    }
  }
View Full Code Here


   
    public void enviarEmail(String endEmail){
        String textoEmail = "Sua unidade recebeu um RMP. Acesse o sistema para maiores informações";
                   
        try{
            SimpleEmail email = new SimpleEmail();
            email.setHostName("smtp.gmail.com");
            email.setSmtpPort(465);
            email.addTo(endEmail);
            email.setFrom("compartilhartrabalhos@gmail.com", "BSI");
            email.setSubject("Voce tem um novo RMP");
            email.setMsg(textoEmail);
            email.setSSL(true);
            email.setAuthentication("compartilhartrabalhos@gmail.com", "bsi2012102");
            email.send();
        }
        catch (EmailException e){
            System.out.println("Erro " + e);
        }  
    }
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

    @Test
    public void testSendEmail() throws EmailException {
         EmailConfig emailConfig = new EmailConfig().
                 setAuthenticator(new DefaultAuthenticator("miguelvega.name@gmail.com", "Mavp8584")).
                 setFrom("miguelvega.name@gmail.com").setHostName("smtp.googlemail.com").setSSL(true).setSmtpPort(465);
        SimpleEmail simpleEmail = emailConfig.newSimpleEmail();

        simpleEmail.setSubject("hello world!");
        simpleEmail.setMsg("This is a simple plain text email");
        simpleEmail.addTo("mikevegap@gmail.com", "mike");

        simpleEmail.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

     * @param subject
     * @param message
     */
  public void send(String server, int port, String username, String password, boolean useSSL,
          String from, String fromDescr, String to, String toDescr, String subject, String message) {
    _mail = new SimpleEmail();
    try {
            setUp(server, port, username, password, useSSL, from, fromDescr, to, subject, message);
            start();
    }
    catch(EmailException e) {
View Full Code Here

     * @param message
     */
  public void sendWithReplyTo(String server, int port, String username, String password, boolean useSSL,
          String from, String fromDescr, String to, String toDescr,
          String replyTo, String replyToDesc, String subject, String message) {
    _mail = new SimpleEmail();
    try {
            setUp(server, port, username, password, useSSL, from, fromDescr, to, subject, message);
            List<InternetAddress> addressColl = new ArrayList<InternetAddress>();
      addressColl.add(new InternetAddress(replyTo, replyToDesc));
      _mail.setReplyTo(addressColl);
View Full Code Here

      logger.error(noMailingListMessage());
      return;
    }
   
    try {
      SimpleEmail email = createEmailFor(msg, e);
      mailer.send(email);
    } catch (Exception ex) {
      logger.error("Unable to send error by email. THIS IS HARDCORE, nobody will know about this error.", ex);
    }
  }
View Full Code Here

TOP

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

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.