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

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

Introduction

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

Prototype

public Email setSSLOnConnect(final boolean ssl) 

Source Link

Document

Sets whether SSL/TLS encryption should be enabled for the SMTP transport upon connection (SMTPS/POPS).

Usage

From source file:com.clavain.alerts.Methods.java

private static void sendMail(String title, String message, String emailaddy) {
    try {/*from   www . j  a v a2s.c  o m*/
        Email email = new SimpleEmail();
        email.setHostName(p.getProperty("mailserver.host"));
        email.setSmtpPort(Integer.parseInt(p.getProperty("mailserver.port")));
        if (p.getProperty("mailserver.useauth").equals("true")) {
            email.setAuthentication(p.getProperty("mailserver.user"), p.getProperty("mailserver.pass"));
        }
        if (p.getProperty("mailserver.usessl").equals("true")) {
            email.setSSLOnConnect(true);
        } else {
            email.setSSLOnConnect(false);
        }
        email.setFrom(p.getProperty("mailserver.from"));
        email.setSubject("[MuninMX] " + title);
        email.setMsg(message);
        email.addTo(emailaddy);
        email.send();
    } catch (Exception ex) {
        logger.warn("Unable to send Mail: " + ex.getLocalizedMessage());
    }
}

From source file:com.qwazr.connectors.EmailConnector.java

public void sendEmail(Email email) throws EmailException {
    email.setHostName(hostname);//from w  w  w.  ja v a  2  s. c o  m
    if (ssl != null)
        email.setSSLOnConnect(ssl);
    if (start_tls_enabled != null)
        email.setStartTLSEnabled(start_tls_enabled);
    if (start_tls_required != null)
        email.setStartTLSRequired(start_tls_required);
    if (port != null)
        email.setSmtpPort(port);
    if (username != null)
        email.setAuthentication(username, password);
    if (connection_timeout != null)
        email.setSocketConnectionTimeout(connection_timeout);
    if (timeout != null)
        email.setSocketTimeout(timeout);
    email.send();
}

From source file:com.qwazr.library.email.EmailConnector.java

public void sendEmail(final Email email) throws EmailException {
    email.setHostName(hostname);//from w  w  w .j  a  v a 2s .c  om
    if (ssl != null)
        email.setSSLOnConnect(ssl);
    if (start_tls_enabled != null)
        email.setStartTLSEnabled(start_tls_enabled);
    if (start_tls_required != null)
        email.setStartTLSRequired(start_tls_required);
    if (port != null)
        email.setSmtpPort(port);
    if (username != null)
        email.setAuthentication(username, password);
    if (connection_timeout != null)
        email.setSocketConnectionTimeout(connection_timeout);
    if (timeout != null)
        email.setSocketTimeout(timeout);
    email.send();
}

From source file:com.mirth.connect.connectors.smtp.DefaultSmtpConfiguration.java

@Override
public void configureEncryption(ConnectorProperties connectorProperties, Email email) throws Exception {
    SmtpDispatcherProperties props = (SmtpDispatcherProperties) connectorProperties;

    if ("SSL".equalsIgnoreCase(props.getEncryption())) {
        email.setSSLOnConnect(true);
        email.setSslSmtpPort(props.getSmtpPort());
    } else if ("TLS".equalsIgnoreCase(props.getEncryption())) {
        email.setStartTLSEnabled(true);//from  w w w .j  a va  2  s . c  o m
    }
}

From source file:br.com.jvmsoftware.util.EnviarMail.java

public void emailSimples(PubConfigEmpresa conf, PubUsuario usu, String msg, String subj) throws EmailException {

    Email email = new SimpleEmail();
    email.setHostName(conf.getMailEnvioSmtp());
    email.setSmtpPort(conf.getMailEnvioPorta());
    email.setAuthenticator(new DefaultAuthenticator(conf.getMailEnvio(), conf.getMailEnvioSenha()));
    email.setSSLOnConnect(true);
    email.setFrom(conf.getMailEnvio());/*  ww w  . ja  va  2s  . co m*/
    email.setSubject(subj);
    email.setMsg(msg);
    email.addTo(usu.getEmail());
    email.send();
}

From source file:com.cognifide.qa.bb.email.EmailSender.java

public void sendEmail(final EmailData emailData) {
    try {/*from   www .  jav a 2  s. c  o  m*/
        Email email = new SimpleEmail();
        email.setHostName(smtpServer);
        email.setSmtpPort(smtpPort);
        email.setAuthenticator(new DefaultAuthenticator(username, password));
        email.setSSLOnConnect(secure);
        email.setFrom(emailData.getAddressFrom());
        email.setSubject(emailData.getSubject());
        email.setMsg(emailData.getMessageContent());
        email.addTo(emailData.getAddressTo());
        email.send();
    } catch (org.apache.commons.mail.EmailException e) {
        throw new EmailException(e);
    }
}

From source file:beanView.MbVListaEmail.java

public void sendMail() {
    String subject = nombre + " " + eMail;
    try {/*  ww w .  jav a2 s . co m*/

        Email email = new SimpleEmail();
        email.setHostName("smtp.gmail.com");
        email.setSmtpPort(465);
        email.setAuthenticator(new DefaultAuthenticator("altabar.listas", "Nivde017"));
        email.setSSLOnConnect(true);
        email.isStartTLSEnabled();
        email.setFrom("altabar.listas@gmail.com");
        email.setSubject(subject);
        email.setMsg(message);
        email.addTo("eacunagon@gmail.com");
        email.send();
        FacesContext.getCurrentInstance().addMessage(null,
                new FacesMessage(FacesMessage.SEVERITY_INFO, "Listo!", "Lista enviada"));
    } catch (Exception ex) {
        FacesContext.getCurrentInstance().addMessage(null,
                new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error", ex.getMessage()));
        eMail = "";
        nombre = "";
        message = "";

    }

}

From source file:Control.CommonsMail.java

/**
 * Classe que envia E-amil/*from  ww w .j a  v  a  2 s .c  o m*/
 * @throws EmailException
 */
public void enviaEmailSimples(String Msg) throws EmailException {

    Email email = new SimpleEmail();
    email.setDebug(true);
    email.setHostName("smtp.gmail.com"); // o servidor SMTP para envio do e-mail
    //email.setHostName("smtp.pharmapele.com.br"); // o servidor SMTP para envio do e-mail
    email.setSmtpPort(587);
    email.setSSLOnConnect(true);
    email.setStartTLSEnabled(true);
    email.setAuthentication("softwaredeveloperantony@gmail.com", "tony#020567");
    //email.setAuthentication("antony@pharmapele.com.br", "tony#020567");

    //email.setFrom("softwaredeveloperantony@gmail.com"); // remetente
    email.setFrom("antony@pharmapele.com.br"); // remetente
    email.setSubject("Exporta Estoque lojas"); // assunto do e-mail
    email.setMsg(Msg); //conteudo do e-mail
    email.addTo("antony@pharmapele.com.br", "Antony"); //destinatrio

    //email.sets(true);
    //email.setTLS(true);
    try {

        email.send();

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.projetIF4.controller.MailControleur.java

public void mail() throws EmailException {
    Email email = new SimpleEmail();
    email.setCharset("UTF-8");
    email.setHostName("smtp.googlemail.com");
    email.setSmtpPort(465);/*from   ww w .j  a  v a  2 s  . com*/
    email.setAuthenticator(new DefaultAuthenticator("fst.rnu.info@gmail.com", "adminFST123456789"));
    email.setSSLOnConnect(true);
    email.setFrom("fst.rnu.info@gmail.com", "Dpartement Informatique FST");
    email.setSubject(objet);
    email.setMsg(message);
    email.addTo(mailDestination);
    email.send();
}

From source file:FacultyAdvisement.ImagineBean.java

public String submitRequest() {

    String emailCourses = "";

    for (Course c : currentCourses) {
        emailCourses += "<li>" + c.getSubject() + " " + c.getNumber() + "</li>";
    }/*w ww .  ja  v  a2  s  . c  om*/

    try {
        Email email = new HtmlEmail();
        email.setHostName("smtp.googlemail.com");
        email.setSmtpPort(465);
        email.setAuthenticator(new DefaultAuthenticator("uco.faculty.advisement", "!@#$1234"));
        email.setSSLOnConnect(true);
        email.setFrom("uco.faculty.advisement@gmail.com");
        email.setSubject("Microsoft Imagine Account");
        email.setMsg("<font size=\"3\" style=\"font-family:verdana\"> \n" + "<ul><li>Student Name: "
                + student.getFirstName() + " " + student.getLastName() + "</li><li>Student Major: "
                + student.getMajorCode() + "<li>Current Courses: <ol>" + emailCourses + "</ol></li></ul> "
                + "Student Email if needed for response: " + student.getUsername()
                + "\n<p align=\"center\">UCO Faculty Advisement</p></font>");
        email.addTo("uco.faculty.advisement@gmail.com");
        email.send();
    } catch (EmailException ex) {
        Logger.getLogger(VerificationBean.class.getName()).log(Level.SEVERE, null, ex);
    }

    return "/customerFolder/imagineConfirm";
}