I get this error when I try to send an email from a Java web application hosted on AWS.
I already tried changing the SMTP server to smtp.live.com , as well as smtp-mail.outlook.com , none of them work.
Could there be some kind of AWS configuration? It works on Ubuntu. (There are no outgoing restrictions on the server itself; there may be some on the Java server)
Code for sending email:
final String username = smtpUsername; final String password = smtpPwd; Properties props = new Properties(); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.host", smtpHost); props.put("mail.smtp.port", smtpPort); Session session = Session.getInstance(props, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(username, password); } }); try { Message message = new MimeMessage(session); message.setFrom(new InternetAddress(smtpUsername)); message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(sendTo)); message.setSubject(subject); message.setContent(content); Transport.send(message); System.out.println("Sent"); } catch (MessagingException e) { e.printStackTrace(); }
The most interesting part of this is that it works from my local computer ... (but only when I turn off Avast)
I tried to run telnet smtp.office365.com 587 , and the result was:
Trying 132.245.195.162... Connected to outlook-emeawest2.office365.com. Escape character is '^]'. 220 HE1PR08CA0021.outlook.office365.com Microsoft ESMTP MAIL Service ready at Wed, 26 Aug 2015 14:32:11 +0000
I tried setting up AWS SMTP ( SES ), and I get the same error, even after I followed the documentation, I also added the email from which I sent and to which I sent verified emails (white list):
javax.mail.MessagingException: Unknown SMTP host: "email-smtp.eu-west-1.amazonaws.com";
source share