1
I am trying to send mail by java but am having an error with smtp. My code:
try {
SimpleEmail mail = new SimpleEmail();
mail.setFrom("[email protected]", "Teste");
mail.setSubject("E-mail exemplo");
mail.setMsg("E-mail de exemplo");
email.setStartTLSEnabled(true);
mail.setAuthentication("[email protected]", "********");
mail.setHostName("smtp.gmail.com");
mail.addTo("[email protected]", "Lucas Souza");
mail.setSmtpPort(587);
mail.send();
} catch (EmailException ex) {
Logger.getLogger(Email.class.getName()).log(Level.SEVERE, null, ex);
}
The error is in the mail line.send():
org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.gmail.com:467
I wonder why my mistake is in smtp 465 if I’m putting 587.
Improved, now it at least gives the error in port 587 aheuhaueh
– Lucas Moraes de Souza