日期:2014-05-20  浏览次数:20775 次

使用MailSender发送简单邮件的问题
各位大侠们教教小弟这个是怎么回事??
为什么发送邮件的时候会出现
Authentication failed: null; nested exception is javax.mail.AuthenticationFailedException 的异常?

请问要如何解决?

我在Spring中的配置是

<bean id="mailMessage" class="org.springframework.mail.SimpleMailMessage">
<property name="from">
<value>wangspringtext@163.com</value>
</property>
<property name="subject">
<value>竞价通知</value>
</property>
</bean>

<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host">
<value>smtp.163.com</value>
</property>
<property name="javaMailProperties">
<props>
<prop key="mail.smtp.auth">true</prop>
<prop key="mail.smtp.timeout">25000</prop>
</props>
</property>
<property name="username">
<value>wangspringtext</value>
</property>
<property name="password">
<value>9706171com</value>
</property>

</bean>


注意: wangspringtext用户名和密码我可以在mail.163.com 网站上正常登录:

下面是我发送邮件的代码:
  private BidDao bidDao;
private AuctionUserDao auctionUserDao;
private ItemDao itemDao;
private SimpleMailMessage message;
private MailSender mailSender;
   
  setter方法省略

SimpleMailMessage msg = new SimpleMailMessage(this.message);
System.out.println(au.getEmail());
msg.setTo(au.getEmail());
msg.setText(
"Dear" + au.getUsername() + ", 谢谢你参与竞价,你的竞价的物品的是: " + item.getItemName()

);

try
{
System.out.println("ghghgh");
mailSender.send(msg);
}
catch(Exception ex)
{
System.err.println(ex.getMessage());
}


注意:
mailSender.send(msg); 上面的System.out.println("ghghgh");能正常输出


------解决方案--------------------
163的估计发布出去!