Ond*_*kar 5 java ubuntu smtp amazon-web-services
当我尝试从AWS上托管的Java Web应用程序发送电子邮件时,我收到此错误.
我已经尝试将SMTP服务器更改为smtp.live.com,而且smtp-mail.outlook.com这些都不起作用.
可以是一些AWS配置吗?它运行在Ubuntu上.(服务器本身没有出站限制,但Java服务器上可能有一些限制)
发送电子邮件的代码:
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();
}
Run Code Online (Sandbox Code Playgroud)
最有趣的部分是,它可以在我的本地计算机上运行...(但仅当我禁用Avast时)
我试图执行telnet smtp.office365.com 587,结果是:
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
Run Code Online (Sandbox Code Playgroud)
我已经尝试设置AWS SMTP(SES)并且我收到相同的错误,即使在我按照文档后,我还添加了我发送的电子邮件以及我发送到已验证电子邮件(白名单)的电子邮件:
javax.mail.MessagingException: Unknown SMTP host: "email-smtp.eu-west-1.amazonaws.com";
Run Code Online (Sandbox Code Playgroud)
尝试从 ubuntu 机器上的 bash shell 进行挖掘
挖 email-smtp.eu-west-1.amazonaws.com
你得到了什么。据我所知,这可能是 DNS 问题。
| 归档时间: |
|
| 查看次数: |
1165 次 |
| 最近记录: |