Before using 163 mailbox e-mail was successful, but the use of China Mobile's own mailbox, regardless of the Linux server is sent unsuccessfully, the first reported the following error:
Javax.mail.MessagingException:Unknown SMTP host:mail.chinamobilesz.com at Com.sun.mail.smtp.SMTPTransport.openSer Ver (smtptransport.java:1959) ~ [Mai l-1.4.7.jar:1.4.7] at Com.sun.mail.smtp.SMTPTransport.protocolConnect (smtptransport.java:65 4) ~[mail-1.4.7.jar:1.4.7] at javax.mail.Service.co Nnect (service.java:317) ~[mail-1.4.7.jar:1.4.7] at Javax.mail.Service.connect (service.java:176) ~[mail-1.4.7.jar:1 .4.7] at Javax.mail.Service.connect (service.java:125) ~[mail-1.4.7.jar:1.4.7] at Javax.mail.Transport.send0 ( transport.java:194) ~[mail-1.4.7.jar:1.4.7 ] at Javax.mail.Transport.send (transport.java:124) ~[mail-1.4.7.jar:1.4.7 "at Com.cmsz.processOm.ser Vice.impl.EmailSendServicEimpl.sendemail (EmailS Endserviceim pl.java:107) ~[emailsendserviceimpl.class:na] at com.cmsz.processom.controller.workordercontroller$ Sendemail.issendema Il (workordercon TROLLER.JAVA:555) [Workordercontroller$sendemail.class:na] at com.cmsz.processom.controller.workordercontroller$ Sendemail.run (Worko Rdercontroller. java:524) [Workordercontroller$sendemail.class:na] at Java.lang.Thread.run (thread.java:745) [na:1.7.0.11] ...
Telnet in Linuxmail.chinamobilesz.comIt doesn't make sense, but it directlymail.chinamobilesz.com for IP to be able to find information on the Internet and refer to other articles, set the host name and IP mapping after finally telnet successfully connected:Reference: http://blog.csdn.net/mchdba/article/details/49339715
However, despite the successful connection of Telnet, the start of the project after sending the message still error, but changed a mistake:
Javax.mail.MessagingException:Could not connect to SMTP host:mail.chinamobilesz.com, port:25 at COM.SUN.MAIL.SMT P.smtptransport.openserver (smtptransport.java:1961) ~[mail-1.4.7.jar:1.4.7] at Com.sun.mail.smtp.SMTPTransport.protocolConnect (smtptransport.java:654) ~[mail-1.4.7.jar:1.4.7] at Javax.mail.Service.connect (service.java:317) ~[mail-1.4.7.jar:1.4.7] at Javax.mail.Service.connect (Service.java : 176) ~[mail-1.4.7.jar:1.4.7] at Javax.mail.Service.connect (service.java:125) ~[mail-1.4.7.jar:1.4.7] at JAV Ax.mail.Transport.send0 (transport.java:194) ~[mail-1.4.7.jar:1.4.7] at Javax.mail.Transport.send (Transport.java : 124) ~[mail-1.4.7.jar:1.4.7] at Com.cmsz.processOm.service.impl.EmailSendServiceImpl.sendEmail ( emailsendserviceimpl.java:107) ~[emailsendserviceimpl.class:na] at Com.cmsz.processom.controller.workordercontroller$sendemail.issendemail (workordercontroller.java:555) [ Workordercontroller$sendemail.class:na] AT Com.cmsz.processom.controller.workordercontroller$sendemail.run (workordercontroller.java:524) [ Workordercontroller$sendemail.class:na] at Java.lang.Thread.run (thread.java:745) [na:1.7.0.11] ...
Find a lot of information or can not solve the problem, do not understand clearly can telnet, why to the program is not connected. So toss for a long time, eventually by the team leader to solve the problem, I finally know the reason. The following code in the project resulted in:
SSL encryption mailsslsocketfactory SF = NULL; try { SF = new Mailsslsocketfactory (); Set to trust all hosts sf.settrustallhosts (true); Proerties.put ("Mail.smtp.ssl.enable", "true"); Proerties.put ("Mail.smtp.ssl.socketFactory", SF); } catch (Generalsecurityexception e) { e.printstacktrace (); }
After using this piece of code, the connection is 465 port, not 25, but actually mobile provided to my mailbox does not open 465 this port, so it is no matter whether 465 or 25 ports are connected, so after removing this code, the startup project to send the message again succeeded.
The hole that Java encounters when sending mail