I’ve been working on a Grails application that sends reminder emails using the Grails Mail plugin. Everything was working fine when I tested it locally. But when I deployed it to the test server, I started seeing the following exception every time it tried to send an email (I’ll spare you the long stacktrace)…

javax.mail.MessagingException: 501 Syntax: HELO hostname

I Googled around and found a number of articles and blog posts that all said the same thing – that the host name is not properly set on the server. In my case, the server host name was set just fine. I was left scratching my head until I found one StackOverflow post that referenced the /etc/hosts file. I took a peak at the server and realized that the hosts file was complete wrong. Instead of    mydevbox

it was…


…a simple mistake by the sysadmin. But it completely broke the Java Mail API.

This mistake was also causing the following ehCache exception during app startup.

ERROR ehcache.Cache  - Unable to set localhost. 
This prevents creation of a GUID. Cause was: mydevbox: mydevbox
java.net.UnknownHostException: mydevbox: mydevbox

A simple change to the /etc/hosts solved both problems.

Like this post? Please share it! Then follow us on Twitter – @thorntech – and sign up for our email list below for future updates.