我在Spring中使用SimpleMailMessage和MailSender发送邮件。我已将.xml文件配置为
<bean id="mailSender" class ="org.springframework.mail.javamail.JavaMailSenderImpl" >
<property name="host" value="smtp.gmail.com" />
<property name="port" value="465" />
<property name="protocol" value="smtps"></property>
<property name="username" value="userId@gmail.com" />
<property name="password" value="passward" />
<property name="endoding" value="UTF-8"></property>
<property name="javaMailProperties">
<props>
<prop key="mail.smtp.starttls.enable">true</prop>
<prop key="mail.smtps.auth">true</prop>
</props>
</property>
<bean id="userRegistrationService" class="UserRegistrationService">
<property name="mailSender" ref="mailSender" />
<property name="userEmailIds">
<set>
<value>abc@gmail.com</value>
<value>abc@yahoo.co.in</value>
</set>
</property>
</bean>
</bean>
但我收到错误:
Failed messages: com.sun.mail.smtp.SMTPSendFailedException: 530-5.5.1 Authentication Required.
Learn more at
530 5.5.1 http://mail.google.com/support/bin/answer.py?answer=14257 i7sm235670pbj.90
可能是什么原因?
答案 0 :(得分:0)
您是否查看了Google's site上的配置指南?例如,如果465导致问题,您可以尝试将邮件端口设置为587。
答案 1 :(得分:0)
协议写成smtps它应该是smtp