A few days ago, when using JavaMail to send Mail on a Linux server, it always reported javax.mail.messagingexception:501 syntax:helo hostname this error, In the confirmation of the message sent by the host is not a problem, and in the local Windows environment, it is normal to send, this is a bit weird, it is not recently good character. Well, after a toss, I finally found the reason.
Solution:
1, first use hostname to view the server's host name, and then the local exploratory ping this hostname, unfortunately found not the corresponding IP host.
2, modify/etc/hosts file, add hostname name corresponding to the 127.0.0.1 top, OH. Send a message at a time, success.
Reason:
JavaMail send a message, will be extracted after the local hostname, will be the form of IP to send mail, but under the Linux server, can not resolve the hostname corresponding native IP address, resulting in JavaMail can not invoke IP send. Postfix received this message will refuse to send, resulting in a 501 error. (Windows Server can send, is because of the use of the non-NetBIOS protocol to obtain the host's IP address, so you can obtain IP)
screenshot Operation: