// 发送注册邮件开始
JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl();
javaMailSender.setHost("smtp.sohu.com");
Properties pro = new Properties();
pro.setProperty("mail.smtp.auth","true");
javaMailSender.setJavaMailProperties(pro);
javaMailSender.setUsername("[email protected]");
javaMailSender.setPassword("123456");
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
MimeMessageHelper messageHelper = new MimeMessageHelper(mimeMessage,
true, "utf-8");
messageHelper.setFrom("[email protected]");
messageHelper.setTo(email);
messageHelper.setSubject("修改密码邮件!");
String content = "<html><head><title>修改密码邮件</title></head><body>"
+ "<p>尊敬的用户,您的新密码为:</p>"
+ randomPassword
+"<p>请及时修改!</p></body></html>";
messageHelper.setText(content, true); // 邮件正文
javaMailSender.send(mimeMessage);
// 发送注册邮件结束执行到javaMailSender.send(mimeMessage);就报错
org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException
[15:24:47.678] {http--8080-2$13326029} org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException
[15:24:47.678] {http--8080-2$13326029} at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:416)
[15:24:47.678] {http--8080-2$13326029} at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:342)
[15:24:47.678] {http--8080-2$13326029} at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:338)
[15:24:47.678] {http--8080-2$13326029} at _jsp._getpassdo__jsp._jspService(_getpassdo__jsp.java:113)
[15:24:47.678] {http--8080-2$13326029} at com.caucho.jsp.JavaPage.service(JavaPage.java:61)
[15:24:47.678] {http--8080-2$13326029} at com.caucho.jsp.Page.pageservice(Page.java:578)
[15:24:47.678] {http--8080-2$13326029} at com.caucho.server.dispatch.PageFilterChain.doFilter(PageFilterChain.java:195)
[15:24:47.678] {http--8080-2$13326029} at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
[15:24:47.678] {http--8080-2$13326029} at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
[15:24:47.678] {http--8080-2$13326029} at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:87)
[15:24:47.678] {http--8080-2$13326029} at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:112)
[15:24:47.678] {http--8080-2$13326029} at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
[15:24:47.678] {http--8080-2$13326029} at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:87)
[15:24:47.678] {http--8080-2$13326029} at cet.util.EnvFilter.doFilter(EnvFilter.java:38)
[15:24:47.678] {http--8080-2$13326029} at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:87)
[15:24:47.678] {http--8080-2$13326029} at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:187)
[15:24:47.678] {http--8080-2$13326029} at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:265)
[15:24:47.678] {http--8080-2$13326029} at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:273)
[15:24:47.678] {http--8080-2$13326029} at com.caucho.server.port.TcpConnection.run(TcpConnection.java:682)
[15:24:47.678] {http--8080-2$13326029} at com.caucho.util.ThreadPool$Item.runTasks(ThreadPool.java:743)
[15:24:47.678] {http--8080-2$13326029} at com.caucho.util.ThreadPool$Item.run(ThreadPool.java:662)
[15:24:47.678] {http--8080-2$13326029} at java.lang.Thread.run(Thread.java:619)
[15:24:47.678] {http--8080-2$13326029} Caused by: javax.mail.AuthenticationFailedException
[15:24:47.678] {http--8080-2$13326029} at javax.mail.Service.connect(Service.java:319)
[15:24:47.678] {http--8080-2$13326029} at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:389)
[15:24:47.678] {http--8080-2$13326029} ... 21 more
麻烦大家帮忙看看了,新浪和搜狐的都报这个错
org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException
[15:24:47.678] {http--8080-2$13326029} org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException
http://howsun.blog.sohu.com/129043957.html
没错,是验证失败,就是想指到怎么用才可以验证通过,后来换了好几个邮箱,发现只有QQ的邮箱现在不需要验证,还是谢谢大家了。平均给分了。3Q