我尝试通过gmail smtp发送邮件通信。请解决这个例外..我在这个问题上一直都是失败的。
java.lang.RuntimeException: javax.mail.AuthenticationFailedException
Filters.Emailer.sendEmail(Emailer.java:51)
org.apache.jsp.registration_jsp._jspService(registration_jsp.java:135)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
根本原因
javax.mail.AuthenticationFailedException
javax.mail.Service.connect(Service.java:319)
javax.mail.Service.connect(Service.java:169)
javax.mail.Service.connect(Service.java:118)
javax.mail.Transport.send0(Transport.java:188)
javax.mail.Transport.send(Transport.java:118)
Filters.Emailer.sendEmail(Emailer.java:47)
org.apache.jsp.registration_jsp._jspService(registration_jsp.java:135)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
答案 0 :(得分:0)
请认可您的代码。正如你所说,我认为你可能没有写出正确的密码认证。试试这个..如果您在评论中提出疑问。
Session session=Session.getDefaultInstance(
properties,new javax.mail.Authenticator(){
protected PasswordAuthentication
getPasswordAuthentication(){
return new PasswordAuthentication
("ganeshp@gmail.com","ganesHp");
}
});