I am trying to send email with Amazon's SES/SMTP and I am getting the following error:
我正在尝试使用亚马逊的SES / SMTP发送电子邮件,我收到以下错误:
javax.mail.MessagingException: Could not connect to SMTP host: email-smtp.us-east-1.amazonaws.com, port: 465, response: -1
javax.mail.MessagingException:无法连接到SMTP主机:email-smtp.us-east-1.amazonaws.com,port:465,响应:-1
Here is how I am trying to send the mail:
以下是我尝试发送邮件的方式:
Spring mail sender config:
Spring邮件发件人配置:
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="${mail.server}"/>
<property name="port" value="${mail.port}"/>
<property name="username" value="${aws.mail.smtp.user}"/>
<property name="password" value="${aws.mail.smtp.password}"/>
<property name="javaMailProperties">
<props>
<!-- Use SMTP-AUTH to authenticate to SMTP server -->
<prop key="mail.smtp.auth">true</prop>
<!-- Use TLS to encrypt communication with SMTP server -->
<prop key="mail.smtp.starttls.enable">true</prop>
</props>
</property>
</bean>
with:
有:
mail.server =email-smtp.us-east-1.amazonaws.com
mail.port = 465
6 个解决方案
#1
12
With amazon SES, configuration needs to be as follows:
使用amazon SES,配置需要如下:
<prop key="mail.smtp.auth">true</prop>
<prop key="mail.smtp.ssl.enable">true</prop>
instead of:
代替:
<prop key="mail.smtp.auth">true</prop>
<prop key="mail.smtp.starttls.enable">true</prop>
as hinted by dave.
正如戴夫所暗示的那样。
EDIT: Please use this solution: https://*.com/a/8928559/536299
编辑:请使用此解决方案:https://*.com/a/8928559/536299
#2
4
Amazon SES SMTP requires the SSL before the SMTP session. The StartTLS command is not supported by SES.
Amazon SES SMTP在SMTP会话之前需要SSL。 SES不支持StartTLS命令。
#3
1
These settings worked for me:
这些设置对我有用:
mail.transport.protocol=smtp mail.smtp.port=25 mail.smtp.auth=true mail.smtp.starttls.enable=true mail.smtp.starttls.required=true mail.smtp.host=email-smtp.us-east-1.amazonaws.com mail.smtp.user=[SMTP username] mail.smtp.password=[SMTP user password]
If you try to connect to connect using SSL connection, it rejected the connection. So you need to do STARTTLS after connection.
如果您尝试使用SSL连接进行连接以进行连接,则会拒绝连接。所以你需要在连接后做STARTTLS。
You can add mail.debug=true to see where it failed.
您可以添加mail.debug = true以查看失败的位置。
The sender email address must be a verified email address otherwise SES refuses to forward the email.
发件人电子邮件地址必须是经过验证的电子邮件地址,否则SES拒绝转发电子邮件。
#4
0
This employee from AWS states that SES does not support SSL at all. https://forums.aws.amazon.com/message.jspa?messageID=218303 .
AWS的这名员工表示SES根本不支持SSL。 https://forums.aws.amazon.com/message.jspa?messageID=218303。
Amazon SES will attempt to send email with Transport Layer Security enabled, but there is not a way to guarantee messages are sent with TLS. SES uses opportunistic TLS when sending emails, which means it will attempt to send emails over TLS first, and then will fall back to regular SMTP if TLS is unavailable.
Amazon SES将尝试发送启用了传输层安全性的电子邮件,但无法保证使用TLS发送邮件。 SES在发送电子邮件时使用机会性TLS,这意味着它将首先尝试通过TLS发送电子邮件,然后在TLS不可用时将回退到常规SMTP。
Hence, I am thinking the issue you are seeing is not TLS or SSL related, rather something else.
因此,我认为您所看到的问题不是TLS或SSL相关,而是其他问题。
#5
0
Note that the AWS note at https://forums.aws.amazon.com/message.jspa?messageID=218303 refers to encrypting server-to-server communication to maintain confidentiality of the email message, is a shared characteristic of all SMTP services.
请注意,https://forums.aws.amazon.com/message.jspa?messageID=218303上的AWS说明是指加密服务器到服务器通信以保持电子邮件的机密性,是所有SMTP服务的共享特征。
This question relates to using a secure connection to the AWS SMTP server to protect the passwords used to authenticate with the AWS server.
此问题涉及使用与AWS SMTP服务器的安全连接来保护用于通过AWS服务器进行身份验证的密码。
#6
0
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:
这些代码已经过测试,效果很好。如果您想使用SMTP over SSL,请配置:
props.setProperty("mail.smtp.starttls.enable", "true");
Or you can download AWS Java SDK from HERE.
或者您可以从HERE下载AWS Java SDK。
Code sample is HERE
代码示例在这里
#1
12
With amazon SES, configuration needs to be as follows:
使用amazon SES,配置需要如下:
<prop key="mail.smtp.auth">true</prop>
<prop key="mail.smtp.ssl.enable">true</prop>
instead of:
代替:
<prop key="mail.smtp.auth">true</prop>
<prop key="mail.smtp.starttls.enable">true</prop>
as hinted by dave.
正如戴夫所暗示的那样。
EDIT: Please use this solution: https://*.com/a/8928559/536299
编辑:请使用此解决方案:https://*.com/a/8928559/536299
#2
4
Amazon SES SMTP requires the SSL before the SMTP session. The StartTLS command is not supported by SES.
Amazon SES SMTP在SMTP会话之前需要SSL。 SES不支持StartTLS命令。
#3
1
These settings worked for me:
这些设置对我有用:
mail.transport.protocol=smtp mail.smtp.port=25 mail.smtp.auth=true mail.smtp.starttls.enable=true mail.smtp.starttls.required=true mail.smtp.host=email-smtp.us-east-1.amazonaws.com mail.smtp.user=[SMTP username] mail.smtp.password=[SMTP user password]
If you try to connect to connect using SSL connection, it rejected the connection. So you need to do STARTTLS after connection.
如果您尝试使用SSL连接进行连接以进行连接,则会拒绝连接。所以你需要在连接后做STARTTLS。
You can add mail.debug=true to see where it failed.
您可以添加mail.debug = true以查看失败的位置。
The sender email address must be a verified email address otherwise SES refuses to forward the email.
发件人电子邮件地址必须是经过验证的电子邮件地址,否则SES拒绝转发电子邮件。
#4
0
This employee from AWS states that SES does not support SSL at all. https://forums.aws.amazon.com/message.jspa?messageID=218303 .
AWS的这名员工表示SES根本不支持SSL。 https://forums.aws.amazon.com/message.jspa?messageID=218303。
Amazon SES will attempt to send email with Transport Layer Security enabled, but there is not a way to guarantee messages are sent with TLS. SES uses opportunistic TLS when sending emails, which means it will attempt to send emails over TLS first, and then will fall back to regular SMTP if TLS is unavailable.
Amazon SES将尝试发送启用了传输层安全性的电子邮件,但无法保证使用TLS发送邮件。 SES在发送电子邮件时使用机会性TLS,这意味着它将首先尝试通过TLS发送电子邮件,然后在TLS不可用时将回退到常规SMTP。
Hence, I am thinking the issue you are seeing is not TLS or SSL related, rather something else.
因此,我认为您所看到的问题不是TLS或SSL相关,而是其他问题。
#5
0
Note that the AWS note at https://forums.aws.amazon.com/message.jspa?messageID=218303 refers to encrypting server-to-server communication to maintain confidentiality of the email message, is a shared characteristic of all SMTP services.
请注意,https://forums.aws.amazon.com/message.jspa?messageID=218303上的AWS说明是指加密服务器到服务器通信以保持电子邮件的机密性,是所有SMTP服务的共享特征。
This question relates to using a secure connection to the AWS SMTP server to protect the passwords used to authenticate with the AWS server.
此问题涉及使用与AWS SMTP服务器的安全连接来保护用于通过AWS服务器进行身份验证的密码。
#6
0
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:
这些代码已经过测试,效果很好。如果您想使用SMTP over SSL,请配置:
props.setProperty("mail.smtp.starttls.enable", "true");
Or you can download AWS Java SDK from HERE.
或者您可以从HERE下载AWS Java SDK。
Code sample is HERE
代码示例在这里