Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

amazon web services - Could not connect to SMTP host: email-smtp.us-east-1.amazonaws.com, port: 465, response: -1

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: email-smtp.us-east-1.amazonaws.com, port: 465, response: -1

Here is how I am trying to send the mail:

Spring mail sender config:

<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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

With amazon SES, configuration needs to be as follows:

<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://stackoverflow.com/a/8928559/536299


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...