Syntactically invalid HELO argument(s)
Just been going trough a lot of reconfiguration lately and today finished configuring a new server. While testing the mail function we saw in the mail logs the following lines:
javax.mail.MessagingException - 501 Syntactically invalid HELO argument(s)
First we thought, it is the application server or sendmail/exim not being properly configured. But as we soon found out, one simply needs to have a valid hostname set for the server. In other words, this error is commonly caused by the hostname of the machine being wrong compared to what the mailserver expects. Java mail does a getHostName and uses that in the HELO.
And just in case you simply set your hostname with “hostname domain” it will not persist on the next reboot. In order to keep your new hostname you will need to change it in the hostname file itself, as in:
sudo vi /etc/hostname
Do a reboot and all should be good.