等了一个星期都没有人回复啊.惨呵............
现在再发:求牛人啦...spring 配置文件如下:
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="smtp.163.com"/>
<property name="javaMailProperties">
<props>
<prop key="mail.smtp.auth">true </prop>
<prop key="mail.smtp.timeout">25000 </prop> </props>
</property>
<property name="username" value="bobobala123"/>
<property name="password" value="20092009"/>
</bean> <bean id="mailMessage" class="org.springframework.mail.SimpleMailMessage">
<property name="from" value="[email protected]"/>
<property name="subject" value="竞价通知"/>
</bean>
不道知为什么总是报错(换了126,sina等都不行.)
:
Authentication failed; nested exception is javax.mail.AuthenticationFailedException 网上也查到了很多类似的问题,但是没有人给出正确的解决方法,望牛人解决!!!!!!!!!!
现在再发:求牛人啦...spring 配置文件如下:
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="smtp.163.com"/>
<property name="javaMailProperties">
<props>
<prop key="mail.smtp.auth">true </prop>
<prop key="mail.smtp.timeout">25000 </prop> </props>
</property>
<property name="username" value="bobobala123"/>
<property name="password" value="20092009"/>
</bean> <bean id="mailMessage" class="org.springframework.mail.SimpleMailMessage">
<property name="from" value="[email protected]"/>
<property name="subject" value="竞价通知"/>
</bean>
不道知为什么总是报错(换了126,sina等都不行.)
:
Authentication failed; nested exception is javax.mail.AuthenticationFailedException 网上也查到了很多类似的问题,但是没有人给出正确的解决方法,望牛人解决!!!!!!!!!!
http://www.softstack.com/freesmtp.html不过你想测试能否正常发送邮件还是很麻烦的,现在的免费邮件服务商都会检测你的ip和你的域名的ip,不同的话会被当成垃圾邮件收不到,一两封邮件还是可以的
<property name="host" value="smtp.163.com"/>
<property name="username" value="[email protected]"/>
<property name="password" value="123456"/>
<property name="javaMailProperties">
<props>
<prop key="mail.smtp.auth">true</prop>
</props>
</property>
</bean>
<!--struts 配置,如果没有用可以不配配置-->
<bean name="/mailAction" class="com.mellow.mail.struts.action.MailActionAction">
<property name="sender" ref="Sender"></property>
</bean>
调用类
public class MailActionAction extends DispatchAction { private JavaMailSender sender; public void setSender(JavaMailSender sender) {
this.sender = sender;
} public ActionForward sender(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// TODO Auto-generated method stub
response.setCharacterEncoding("utf-8");
try {
request.setCharacterEncoding("utf-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String userName =request.getParameter("userName");
System.out.println(userName);
SimpleMailMessage msg = new SimpleMailMessage();
msg.setFrom("[email protected]");
msg.setTo("[email protected]");
msg.setSubject("注册成功!");
msg.setText("恭喜,您在郑州农产品网上交易平台注册成功!您的用户名为"+userName);
sender.send(msg);
return null;
}}
可以成功的,楼主你可以试试
[email protected]