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

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

Introduction

In this page you can find the example usage for org.apache.commons.mail SimpleEmail 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:model.Email.java

public static void sendToken(String receiver, String token) throws EmailException {

    SimpleEmail email = new SimpleEmail();
    String message = "Para sua segurana, voc precisa colocar o cdigo abaixo para continar a transao.\n";
    message += "Token: " + token + "\n";
    message += "\nO sistema de token  para sua segurana, sempre ao realizar uma transao, um novo token  gerado ";
    message += " e enviado  voc.";

    try {/*from w ww .  ja  v  a 2s  .c  om*/
        email.setHostName("smtp.googlemail.com");
        email.setSmtpPort(465);
        email.setAuthenticator(new DefaultAuthenticator("totheworldgroup@gmail.com", "albrcalu"));
        email.setSSLOnConnect(true);
        email.setFrom("totheworldgroup@gmail.com");
        email.setSubject("Token para realizar transao");
        email.setMsg(message);
        email.addTo(receiver);
        email.send();

    } catch (EmailException e) {
        System.out.println(e.getMessage());
    }

}

From source file:model.Email.java

public static void sendConfirmation(String receiver, String token, PersonalAccount account)
        throws EmailException {

    SimpleEmail email = new SimpleEmail();
    String message = "Sua conta foi criada com sucesso, porm ainda est inativa.\n";
    message += "Nmero da conta: " + account.getNumber() + "\n";
    message += "Agncia: " + account.getAgency().getNumber() + "\n";
    message += "Token de autentificao: " + token + "\n";
    message += "Com este token voc  capaz de definir uma senha para sua conta para, ento, utiliz-la.\n";
    message += "\nCaso voc perca este token, entre novamente com as informaes para abrir conta,";
    message += " e um novo token ser gerado e reenviado  voc.";

    try {/*from w  w w . j  a va2s. c o m*/
        email.setHostName("smtp.googlemail.com");
        email.setSmtpPort(465);
        email.setAuthenticator(new DefaultAuthenticator("totheworldgroup@gmail.com", "albrcalu"));
        email.setSSLOnConnect(true);
        email.setFrom("totheworldgroup@gmail.com");
        email.setSubject("Token de autentificao");
        email.setMsg(message);
        email.addTo(receiver);
        email.send();

    } catch (EmailException e) {
        System.out.println(e.getMessage());
    }

}

From source file:com.bc.appbase.ui.dialog.SendReportAction.java

private static Email getEmail(String host, int port, String emailAddress, String password, String subject) {

    final SimpleEmail email = new SimpleEmail();

    try {// ww  w . jav  a2s  .  com
        email.addTo(emailAddress);
    } catch (EmailException e) {
        logger.log(Level.WARNING,
                "Error add `to address`: " + emailAddress + " to email with subject: " + subject, e);
        return null;
    }

    if (password != null) {
        email.setAuthentication(emailAddress, password);
    }
    email.setDebug(logger.isLoggable(Level.FINE));

    try {
        email.setFrom(emailAddress);
    } catch (EmailException e) {
        logger.log(Level.WARNING,
                "Error setting `from address` = " + emailAddress + " to email with subject: " + subject, e);
        return null;
    }

    email.setHostName(host);
    email.setSmtpPort(port);

    if (password != null) {
        email.setSSLOnConnect(true);
    }

    email.setSubject(subject);

    return email;
}

From source file:br.edu.ifpb.padroes.projeto.sisbiblioteca.mail.EmprestimoEmail.java

private SimpleEmail createSimpleEmail() {

    SimpleEmail simpleEmail = new SimpleEmail();

    simpleEmail.setHostName(hostName);/*from ww  w  .j  av a  2  s. c om*/
    simpleEmail.setSmtpPort(port);
    simpleEmail.setStartTLSEnabled(true);
    simpleEmail.setSSLOnConnect(true);

    return simpleEmail;
}

From source file:br.com.gamestore.controler.ChamadoControler.java

/**
 * ENVIA EMAIL PARA O USU?RIO, RESPONDENDO O CHAMADO MESMO
 * @param email/*from w ww. ja  va2 s  .  c o  m*/
 * @param comentario
 * @throws EmailException 
 */
public void enviarEmailChamdo(String email, String comentario) throws EmailException {

    //String emailusuario = request.getParameter("email");
    SimpleEmail simpleemail = new SimpleEmail();
    simpleemail.setHostName("smtp.gmail.com");
    simpleemail.setSmtpPort(465);
    simpleemail.setAuthentication("rkfsystem@gmail.com", "rkfsystemgamestore");
    simpleemail.setSSLOnConnect(true);
    simpleemail.setFrom("rkfsystem@gmail.com");
    simpleemail.setSubject("RESPOST DO CHAMADO");
    simpleemail.setMsg(comentario);
    simpleemail.addTo(email);
    simpleemail.send();

}

From source file:br.com.gamestore.controler.UsuarioControler.java

/**
 * ENVIA O EMAIL COM A SENHA DO USU?RIO, QUANDO O MESMO FOR CRIADO
 * @param senha/*from w w w .j  av a  2 s. c o  m*/
 * @param emailusuario
 * @throws EmailException 
 */
public void enviarEmail(String senha, String emailusuario) throws EmailException {

    //String emailusuario = request.getParameter("email");
    SimpleEmail email = new SimpleEmail();
    email.setHostName("smtp.gmail.com");
    email.setSmtpPort(465);
    email.setAuthentication("rkfsystem@gmail.com", "rkfsystemgamestore");
    email.setSSLOnConnect(true);
    email.setFrom("rkfsystem@gmail.com");
    email.setSubject("senha de acesso ao sistema");
    email.setMsg("Senha: " + senha.replaceAll("-", "").substring(0, 5));
    email.addTo(emailusuario);
    email.send();

}

From source file:com.tcc.servidor_tcc.api.SystematicReviewResource.java

private void sendEmailNotification(Reviewer reviewer, boolean registered, SystematicReview sr) {
    SimpleEmail email = new SimpleEmail();
    email.setSSLOnConnect(true);
    email.setHostName("smtp.gmail.com");
    email.setSslSmtpPort("465");
    email.setAuthenticator(new DefaultAuthenticator("mobrevsys@gmail.com", "revisaosistematica"));
    try {/*from   ww w.java  2 s. co m*/
        email.setFrom("mobrevsys@gmail.com");

        email.setDebug(true);

        email.setSubject("MobRevSys - Invited to participate in a Systematic Review");
        if (registered) {
            email.setMsg("Hello " + reviewer.getName() + ",\n" + sr.getOwner().getName()
                    + " has invited you to participate in a " + "Systematic Review with the title of \""
                    + sr.getTitle() + "\".\n" + "Best Regards,\n MobRevSys");
        } else {
            email.setMsg("Hello " + reviewer.getEmail() + ",\n" + sr.getOwner().getName()
                    + "has invited you to participate in a " + "Systematic Review with the title of \""
                    + sr.getTitle() + "\".\n"
                    + "Please download the MobRevSys app and register to contribute.\n"
                    + "Best Regards,\n MobRevSys");
        }
        email.addTo(reviewer.getEmail());

        email.send();

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

From source file:br.vn.Model.Filtros.Email.java

public void envia(String emailcliente) {

    try {// w  w w.j av a  2 s  . c o  m
        SimpleEmail email = new SimpleEmail();
        email.setHostName("smtp.googlemail.com");
        email.setSmtpPort(465);
        email.setAuthentication("Kleriston.firmino@gmail.com", "cavalo15");
        email.setSSLOnConnect(true);
        email.setFrom("teste.ads@gmail.com");
        email.setSubject("Recuperar Senha");
        email.setMsg(
                " [url=\"www.google.com.br\"][img]https://www.google.com.br/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&cad=rja&uact=8&ved=0ahUKEwig17C98bnOAhVClZAKHTIqCEkQjRwIBw&url=http%3A%2F%2Fwww.gigabytetls.com%2F%23!servicos%2Fcjg9&psig=AFQjCNFe4nf3QiYJl9hhHxXmvVESfqvE4g&ust=1471022895224204[/img][/url]");
        email.addTo(emailcliente);
        email.send();
    } catch (EmailException ex) {
        Logger.getLogger(Email.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:br.vn.Controlador.RecuperaSenhaBean.java

public String envia(String emailCliente) {

    c = repCliente.recuperaEmail();/*from   w  w w. j a va  2  s  .  c  o  m*/
    for (int i = 0; i < c.size(); i++) {
        if (c.get(i).getEmail().equals(emailCliente)) {

            try {
                SimpleEmail email = new SimpleEmail();
                email.setHostName("smtp.googlemail.com");
                email.setSmtpPort(465);
                email.setAuthentication("Kleriston.firmino@gmail.com", "cavalo15");
                email.setSSLOnConnect(true);
                email.setFrom("teste.ads@gmail.com");
                email.setSubject("Recuperar Senha");
                email.setMsg("Ateno: " + c.get(i).getNome() + " Para Recuperar Sua Senha Click Aqui ===>"
                        + "http://localhost:8084/Restaurante/faces/faces/RecuperarSenha.xhtml");
                email.addTo(emailCliente);

                email.send();
            } catch (EmailException ex) {
                Logger.getLogger(Email.class.getName()).log(Level.SEVERE, null, ex);
            }
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Ateno! "
                    + " Em Instantes Voc Receber Um Email Com as Instrues Para Recuperar Sua Senha!"));
            return "/index.xhtml";
        }

    }
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Ateno! " + " Email Incorreto!"));
    return "/EnviarEmail.xhtml";
}

From source file:br.vn.Controlador.ControladorClienteBean.java

public void inserir() {
    if (this.confirma.equals(this.cliente.getSenha())) {

        try {/*www .  java  2 s. c  o m*/
            cliente.setEndereco(endereco);

            repCliente.inserir(cliente);

            FacesContext.getCurrentInstance().addMessage(null,
                    new FacesMessage("Parabns! " + " Cliente Cadastrado Com Sucesso!"));

            Endereco e = new Endereco();
            endereco.setBairro(e.getBairro());
            endereco.setCidade(e.getCidade());
            endereco.setLogradouro(e.getLogradouro());
            endereco.setNumero(e.getNumero());

            RepositorioEndereco repEnd = new RepositorioEndereco();

            repEnd.inserir(endereco);

            SimpleEmail email = new SimpleEmail();
            email.setHostName("smtp.googlemail.com");
            email.setSmtpPort(465);
            email.setAuthentication("Kleriston.firmino@gmail.com", "cavalo15");
            email.setSSLOnConnect(true);
            email.setFrom("teste.ads@gmail.com");
            email.setSubject("O Velho Nordestino");
            email.setMsg("Bem Vindo: " + cliente.getNome() + ", Cadastro Efetuado Com Sucesso!");
            email.addTo(cliente.getEmail());

            email.send();

            Cliente c = new Cliente();
        } catch (EmailException ex) {
            Logger.getLogger(ControladorClienteBean.class.getName()).log(Level.SEVERE, null, ex);
        }
    } else {
        FacesContext.getCurrentInstance().addMessage(null,
                new FacesMessage("Ateno! " + " Senha Incorreta!"));
    }

}