I am trying to send email with Amazon\'s SES/SMTP and I am getting the following error:
javax.mail.MessagingException: Could not connect to SMTP host: em
Properties props = new Properties();
props.setProperty("mail.transport.protocol", "smtp");
props.setProperty("mail.smtp.auth", "true");
props.setProperty("mail.host", "email-smtp.us-east-1.amazonaws.com");
props.setProperty("mail.user", "your_ses_user");
props.setProperty("mail.password", "your_ses_pwd");
Session mailSession = Session.getDefaultInstance(props, new Authenticator(){
public PasswordAuthentication getPasswordAuthentication() {
String username = "your_ses_user";
String password = "your_ses_pwd";
return new PasswordAuthentication(username, password);
}
});
These code have been tested, works fine well. If you want use SMTP over SSL, please config:
props.setProperty("mail.smtp.starttls.enable", "true");
Or you can download AWS Java SDK from HERE.
Code sample is HERE