Error with the commons Mail "Sending the email to the following server failed: smtp.googlemail.com:465"

2

Hello. I'm trying to send an email from java and I'm using commons mail and javamail for this. More is giving error ... Follow method. I've already changed the .. "Allow less secure apps" in gmail

public void enviarEmail(String emailDeDestino, String assunto, String corpo)throws EmailException {

    Email email = new SimpleEmail();
    email.setHostName("smtp.googlemail.com");
    email.setAuthentication("[email protected]", "XXXXXXXXXX");
    email.setSSLOnConnect(true);
    email.setFrom(emailDeDestino);
    email.setSubject(assunto);
    email.setMsg(corpo);
    email.addTo(emailDeDestino);
    email.send();
}
    
asked by anonymous 12.09.2018 / 04:54

0 answers