如何为hotmail配置Spring JavaMailSenderImpl

时间:2016-07-14 06:08:14

标签: java spring email spring-mvc

这是我在maven项目中的xml配置文件,我正在尝试使用hotmail id发送自动生成的消息,有时它工作正常并且somoetimes我收到错误发送邮件

<bean id=" email" class=" org.springframework.mail.SimpleMailMessage"></bean>




    <bean class="org.springframework.mail.javamail.JavaMailSenderImpl"    id="mailSender">





        <property value="smtp.live.com" name="host" />




        <property value="587" name="port" />




        <property value="xxxxxx@hotmail.com" name="username" />




        <property value="xxxxxxxxx" name="password" />




        <property name="javaMailProperties">




            <props>




                <prop key="mail.transport.protocol">smtp</prop>




                <prop key="mail.smtp.auth">true</prop>




                <prop key="mail.smtp.starttls.enable">true</prop>




                   <prop key="mail.smtp.socketFactory.port">465</prop>  




<prop key="mail.smtp.socketFactory.class">javax.net.ssl.SSLSocketFactory</prop>  




 <prop key="mail.smtp.port">465</prop>  




</props>




</property>




</bean>

1 个答案:

答案 0 :(得分:0)

将端口名称587更改为25后,它正常工作