org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.mxhichina.com:25
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1138)
at org.apache.commons.mail.Email.send(Email.java:1163)
......
Caused by: javax.mail.MessagingException: 500 Error: bad syntax
at com.sun.mail.smtp.SMTPTransport.issueCommand(SMTPTransport.java:1363)
at com.sun.mail.smtp.SMTPTransport.helo(SMTPTransport.java:838)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:375)
at javax.mail.Service.connect(Service.java:297)
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 org.apache.commons.mail.Email.sendMimeMessage(Email.java:1128)
... 46 more
原因
阿里云服务没有配置正确的host。执行命令:
hostname -i
结果如果不是127.0.0.1 。如果不是那么,
解决办法:
首先在Linux命令行中查看 hostname
#hostname
xxxxxxxx //hostname
然后在/etc/hosts中添加一行
127.0.0.1 xxxxxxxx
即可解决问题。