Example usage for org.apache.commons.mail Email setSmtpPort

List of usage examples for org.apache.commons.mail Email setSmtpPort

Introduction

In this page you can find the example usage for org.apache.commons.mail Email setSmtpPort.

Prototype

public void setSmtpPort(final int aPortNumber) 

Source Link

Document

Set the port number of the outgoing mail server.

Usage

From source file:at.tugraz.kmi.medokyservice.ErrorLogNotifier.java

public static void errorEmail(String msg) {

    Email email = new SimpleEmail();
    email.setHostName("something.com");
    email.setSmtpPort(465);
    DefaultAuthenticator auth = new DefaultAuthenticator("username", "pwd");
    email.setAuthenticator(auth);//from  w  ww . jav  a  2 s .c o m
    email.setSSLOnConnect(true);
    try {
        email.setFrom("email address");
        email.setSubject("[MEDoKyService] Error");
        email.setMsg(msg);
        email.addTo("yourmail.com");
        email.send();
    } catch (EmailException e) {
        e.printStackTrace();
    }

}

From source file:com.aprodher.actions.util.EmailUtils.java

public static Email conectaEmail() throws EmailException {
    Email email = new SimpleEmail();
    email.setHostName(HOSTNAME);//w  w  w .  j  a v a  2  s. co m
    email.setSmtpPort(587);
    email.setAuthenticator(new DefaultAuthenticator(USERNAME, PASSWORD));
    email.setSSL(true);
    email.setTLS(true);
    email.setFrom(EMAILORIGEM);
    return email;
}

From source file:io.jhonesdeveloper.swing.util.EmailUtil.java

public static void sendBasicText(String hostName, String username, String password, String from, String subject,
        String msg, String[] to) throws EmailException {
    Email email = new SimpleEmail();
    email.setHostName(hostName);/*from   w  w  w.  jav a2s.c  om*/
    email.setSmtpPort(465);
    email.setAuthenticator(new DefaultAuthenticator(username, password));
    email.setSSLOnConnect(true);
    email.setFrom(from);
    email.setSubject(subject);
    email.setMsg(msg);
    email.addTo(to);
    email.send();
}

From source file:de.alpharogroup.message.system.service.CommonsEmailSendService.java

public static void sendEmail(final EmailConfiguration config, InfoMessageModel model) throws EmailException {
    // TODO make class for email config...
    Email email = new SimpleEmail();
    email.setHostName(config.getHostName());
    email.setSmtpPort(config.getSmtpPort());
    email.setFrom(model.getApplicationSenderAddress());
    email.setSubject(model.getMessageContentModel().getSubject());
    email.setMsg(model.getMessageContentModel().getContent());
    email.addTo(model.getRecipientEmailContact());
    email.send();//from w ww. jav  a2s. c  o  m
}

From source file:connection.EmailSending.java

public static void sendTextEmail(String subject, String content, String recipientEmail) {
    Email email = new SimpleEmail();

    email.setHostName(MailInfor.HOST_NAME);
    email.setSmtpPort(465);
    email.setAuthenticator(new DefaultAuthenticator(MailInfor.EMAIL_SENDER, MailInfor.PASSWORD));
    email.setSSLOnConnect(true);//from  w  w  w  .  j  a  v a2s. co m

    try {
        email.setFrom(MailInfor.EMAIL_SENDER);
        email.setSubject(subject);
        email.setMsg(content);
        email.addTo(recipientEmail);

        email.send();
    } catch (EmailException ex) {
        Logger.getLogger(EmailSending.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:controller.SendMailMachine.java

public static void sendMail(Cart cart, String recipientEmail) {
    Email email = new SimpleEmail();

    email.setHostName(HOST_NAME);/*from w w w.  j a v a  2 s .c  o m*/
    email.setSmtpPort(465);
    email.setAuthenticator(new DefaultAuthenticator(EMAIL_SENDER, PASSWORD));
    email.setSSLOnConnect(true);

    String subject = "Thng tin ha n";
    String content = "\t\t\tTRUNG TM MUA SM BITTORRENT\n\nChi tit n hng ca bn: \n";
    for (Map.Entry<Integer, Item> entrySet : cart.getCartItem().entrySet()) {
        Item item = entrySet.getValue();
        content += item.getWatch().getName() + "\t\t\t\t\t\t" + item.getQuantity() + " x "
                + ((int) item.getWatch().getPrice()) + "000 VND\n";
    }
    content += "Tng ha n: " + ((int) cart.sumPrice()) + "000 VND";
    try {
        email.setFrom(EMAIL_SENDER);
        email.setCharset("UTF-8");
        email.setSubject(subject);
        email.setMsg(content);

        email.addTo(recipientEmail);

        email.send();
    } catch (EmailException ex) {

        ex.printStackTrace();
    }
}

From source file:model.EmailJava.java

public static void enviarEmail(String userEmail) {
    try {/* w  w w.jav a  2  s.  com*/
        Email email = new SimpleEmail();
        email.setHostName("smtp.googlemail.com");
        email.setSmtpPort(465);
        //email.setAuthenticator(new DefaultAuthenticator("username", "password"));
        email.setAuthentication("codbarzmgbr@gmail.com ", "streetworkout2014");
        email.setSSLOnConnect(true);

        email.setFrom("jpmuniz88@gmail.com");

        email.setSubject("CodbarZ");
        email.setMsg("Junte-se ao CodbarZ. \n" + "Atleta junte-se ao nosso time, \n"
                + "empreendedores junte-se para nos apoiar, \n"
                + "Associe essa ideia, um projeto de inovado e aberto a todos que desejar evoluir com CodbarZ");
        email.addTo(userEmail);
        email.send();

    } catch (EmailException ex) {
        Logger.getLogger(EmailJava.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:de.maklerpoint.office.Schnittstellen.Email.SimpleEmailSender.java

/**
 * /*from  w w w  . j  av a 2s . c o  m*/
 * @param adress
 * @param Subject
 * @param body
 * @throws EmailException 
 */

public static void sendSimpleEMail(String adress, String Subject, String body) throws EmailException {
    Email email = new SimpleEmail();
    email.setHostName(Config.get("mailHost", ""));
    email.setSmtpPort(Config.getConfigInt("emailPort", 25));

    email.setTLS(Config.getConfigBoolean("mailTLS", false));
    email.setSSL(Config.getConfigBoolean("mailSSL", false));

    //email.setSslSmtpPort(Config.getConfigInt("emailPort", 25));
    email.setAuthenticator(
            new DefaultAuthenticator(Config.get("mailUsername", ""), Config.get("mailPassword", "")));

    email.setFrom(Config.get("mailSendermail", ""), Config.get("mailSender", ""));

    email.setSubject(Subject);
    email.setMsg(body);
    email.addTo(adress);

    email.send();
}

From source file:com.esofthead.mycollab.servlet.InstallUtils.java

public static void checkSMTPConfig(String host, int port, String username, String password, boolean auth,
        boolean isStartTls, boolean isSSL) {
    try {/*ww w.j a va  2 s.c o  m*/
        Properties props = new Properties();
        if (auth) {
            props.setProperty("mail.smtp.auth", "true");
        } else {
            props.setProperty("mail.smtp.auth", "false");
        }
        if (isStartTls) {
            props.setProperty("mail.smtp.starttls.enable", "true");
            props.setProperty("mail.smtp.startssl.enable", "true");
        } else if (isSSL) {
            props.setProperty("mail.smtp.startssl.enable", "false");
            props.setProperty("mail.smtp.ssl.enable", "true");
            props.setProperty("mail.smtp.ssl.socketFactory.fallback", "false");

        }

        Email email = new SimpleEmail();
        email.setHostName(host);
        email.setSmtpPort(port);
        email.setAuthenticator(new DefaultAuthenticator(username, password));
        if (isStartTls) {
            email.setStartTLSEnabled(true);
        } else {
            email.setStartTLSEnabled(false);
        }

        if (isSSL) {
            email.setSSLOnConnect(true);
        } else {
            email.setSSLOnConnect(false);
        }
        email.setFrom(username);
        email.setSubject("MyCollab Test Email");
        email.setMsg("This is a test mail ... :-)");
        email.addTo(username);
        email.send();
    } catch (Exception e) {
        throw new UserInvalidInputException(e);
    }
}

From source file:com.reizes.shiva.net.mail.EmailSender.java

public static String sendMail(String host, int port, String from, String to, String subject, String text)
        throws IOException, EmailException {

    if (to != null && host != null) {
        String[] emailTo = StringUtils.split(to, ';');

        Email email = new SimpleEmail();
        email.setHostName(host);//from w w  w . j  av  a2  s.co m
        email.setSmtpPort(port);
        email.setFrom(from);

        for (String recv : emailTo) {
            email.addTo(recv);
        }

        email.setSubject(subject);
        email.setMsg(text);
        return email.send();
    }

    return null;
}