Java发邮件:Caused by: javax.mail.MessagingException: 500 Error: bad syntax

今天再Linux服务器中执行发送邮件的脚本时遇到如下异常:


Java发邮件:Caused by: javax.mail.MessagingException: 500 Error: bad syntax_第1张图片

 

[com.china.adcrm.stock.StockSchedule.sendEmail(StockSchedule.java:153)] 
2016-01-05 14:48:27 310 [ INFO]  [com.china.adcrm.stock.StockSchedule.sendEmail(StockSchedule.java:167)] 
org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.bj.china.com:25
        at org.apache.commons.mail.Email.sendMimeMessage(Email.java:873)
        at org.apache.commons.mail.Email.send(Email.java:898)
        at com.china.adcrm.stock.StockSchedule.sendEmail(StockSchedule.java:164)
        at com.china.adcrm.stock.StockSchedule.prodContentSendEmail(StockSchedule.java:393)
        at com.china.adcrm.stock.StockSchedule.main(StockSchedule.java:687)
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:863)
        ... 4 more
2016-01-05 14:48:27 311 [ INFO] 向销售发送邮件提前2天的通知 [com.china.adcrm.stock.StockSchedule.main(StockSchedule.java:688)] 

 

然后网上查找下,找到如下解决方案:

 

第一步检查: /etc/hosts是否添加了 127.0.0.1的映射

 

使用以下命令查询

hostname -i

如果返回

hostname : 未知主机

则问题为本次错误原因

正常返回值为:

hostname : 127.0.0.1

出现这种问题,需检查 /etc/sysconfig/network

NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=www.localhost.com

看看是否hostname配置错误

 

直到 hostname -i 值为 127.0.0.1为止!

 

OL,问题解决。
 

你可能感兴趣的:(java,mail,EmailException)