关于java mail 的端口问题

javax.mail.MessagingException:  530   5.7 . 0  Must issue a STARTTLS command first. u12sm73042tia. 38

    at com.sun.mail.smtp.SMTPTransport.issueCommand(SMTPTransport.java:
879 )
    at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:
599 )
    at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:
319 )
    at com.roadway.edmail.util.JMail2.sendMail(JMail2.java:
278 )
    at com.roadway.edmail.bo.feedback.FeedbackSender.sender(FeedbackSender.java:
72 )
    at org.apache.jsp.test_jsp._jspService(test_jsp.java:
59 )
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:
70 )
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:
717 )
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:
374 )
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:
342 )
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:
267 )
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:
717 )
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:
290 )
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:
206 )
    at com.roadway.edmail.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:
20 )
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:
235 )
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:
206 )
    at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:
164 )
    at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:
141 )
    at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:
90 )
    at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:
417 )
    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:
233 )
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:
191 )
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:
128 )
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:
102 )
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:
109 )
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:
286 )
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:
845 )
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:
583 )
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:
447 )
    at java.lang.Thread.run(Thread.java:
619 )

解决方法:
if ( this .smtp.indexOf( " smtp.gmail.com " ) >= 0 )
            
{
                properties.setProperty(
"mail.smtp.socketFactory.class""javax.net.ssl.SSLSocketFactory"); 
                properties.setProperty(
"mail.smtp.socketFactory.fallback""false"); 
                properties.setProperty(
"mail.smtp.port""465"); 
                properties.setProperty(
"mail.smtp.socketFactory.port""465"); 
            }

或者换发送邮箱
一般邮箱端口号为25   
gmail为465或587


你可能感兴趣的:(关于java mail 的端口问题)