linux机器上发送邮件的错误
在发送邮件时报下面的错误
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:275) at javax.mail.Service.connect(Service.java:156)
原因:
首先取得当前主机的主机名:
>hostname
xxxx(xxxx为hostname例如myhostname)
可以得到linux的主机名
>hostname-i
却得不到ip当调用到下面的代码时会报错
InetAddress localHost = InetAddress.getLocalHost(); localHostName = localHost.getHostName();
解决方法:
在/etc/hosts文件中加入
127.0.0.1 xxxx
相关推荐
farwang 2020-11-25
星愿心愿 2020-11-24
tianhuak 2020-11-24
zhjn0 2020-11-24
昭君出塞 2020-11-23
bluecarrot 2020-11-23
linuxwcj 2020-10-21
以梦为马不负韶华 2020-10-20
彼岸随笔 2020-10-20
yutou0 2020-10-17
applecarelte 2020-10-16
ourtimes 2020-10-16
waterhorse 2020-09-19
MRFENGG 2020-11-11
rainandtear 2020-10-30
kyssfanhui 2020-10-20
liuhangtiant 2020-10-20