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

Asked

Viewed 20 times

2

Hello. I’m trying to send an email through java and I’m using Commons-mail and javamail for this. Más está dando erro... It follows method. I 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();
}
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.