当前位置:编程学习 > JAVA >>

关于javamail发邮件问题

在网上找了一下 javamail发邮件的例子   MailSenderInfo.java,SimpleMailSender.java,MyAuthenticator.java三个类

然后写一个方法 内容如下:

      MailSenderInfo mailInfo = new MailSenderInfo();    
      mailInfo.setMailServerHost("smtp.163.com");    
      mailInfo.setMailServerPort("25");    
      mailInfo.setValidate(true);    
      mailInfo.setUserName("han2000lei@163.com");    
      mailInfo.setPassword("**********");//您的邮箱密码    
      mailInfo.setFromAddress("han2000lei@163.com");    
      mailInfo.setToAddress("han2000lei@163.com");    
      mailInfo.setSubject("设置邮箱标题 如http://www.guihua.org 中国桂花网");    
      mailInfo.setContent("设置邮箱内容 如http://www.guihua.org 中国桂花网 是中国最大桂花网站==");    
         //这个类主要来发送邮件   
      SimpleMailSender sms = new SimpleMailSender();   
          //sms.sendTextMail(mailInfo);//发送文体格式    
          sms.sendHtmlMail(mailInfo);//发送html格式   

以前换可以发送  现在发送会报错:
javax.mail.AuthenticationFailedException
at javax.mail.Service.connect(Service.java:306)
at javax.mail.Service.connect(Service.java:156)
at javax.mail.Service.connect(Service.java:105)
at javax.mail.Transport.send0(Transport.java:168)
at javax.mail.Transport.send(Transport.java:98)
at com.vvise.service.base.bssubscibe.SimpleMailSender.sendHtmlMail(SimpleMailSender.java:100)
at com.vvise.web.base.bscustinfo.BsCustInfoAction.sendEmalil(BsCustInfoAction.java:713)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:174)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:72)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:78)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.ecside.filter.ECSideFilter.doFilter(ECSideFilter.java:261)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
麻烦看见的都给我说一下 现在很着急 。。。谢谢大家了 。。。。。

--------------------编程问答-------------------- 我参考这篇JavaMail文章调试成功:JavaMail邮件功能开发 --------------------编程问答-------------------- 用户密码验证失败 是不是你的发送者的邮箱密码写错了 --------------------编程问答--------------------
引用 2 楼  的回复:
用户密码验证失败 是不是你的发送者的邮箱密码写错了



没有是对的   
好像就是密码验证这块是错的 --------------------编程问答--------------------
引用 1 楼  的回复:
我参考这篇JavaMail文章调试成功:JavaMail邮件功能开发

Session sendMailSession = Session.getDefaultInstance(pro,myauth);   

用户名和密码在经过这之后用户名 就改变了 这是什么原因啊???
补充:Java ,  Web 开发
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,