I'm trying to send email via java but I'm 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 you give is in the mail.send () line:
org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.gmail.com:467
I wanted to know why my error is in smtp 465 if I am putting 587.