Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 932
balteo Avatar asked Dec 21 '11 16:12

balteo


2 Answers

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

like image 106
balteo Avatar answered Oct 14 '22 20:10

balteo


Amazon SES SMTP requires the SSL before the SMTP session. The StartTLS command is not supported by SES.

like image 36
dave wanta Avatar answered Oct 14 '22 21:10

dave wanta