Rob Ruder's picture

I've deployed a Turnkey LAMP server. The website has email capabilities but in /var/mail/www-data I find little love letters like this:

host[] said: 504 5.5.2
    <localhost>: Helo command rejected: need fully-qualified hostname (in reply
    to RCPT TO command)

I have dug into PostFix (etc/postfix/, php.ini, and hosts. I've changed and qualified every setting that I can get my hands on, but nothing changes the hostname that is presented to the remote SMTP server when the SMTP header is sent out.  I've even directed messages to a mail server that I manage so that I can see the log entries as the email is recieved and it stubbornly insists on identifying itself as "localhost" whenever it attempts to deliver a mail message.

What am I missing?  I am not a Ubuntu or any flavor of linux master so I need some very specific explanation about how all these different processes fit together so I can understand this system. I'm pretty good at digging around and figuring out what I need to know, but I'm just spinning in circles at the moment.

All help is appreciated.


Jeremy Davis's picture

But the first thing I'd check is that your server has a FQDN (Fully Qualified Domain Name) set. Because of the complaints I'm guessing that it doesn't. What does 'hostname -f' return? If your server is configured correctly it should return your FQDN. If not then the Ubuntu Lucid man page for hostname suggests that you add an entry to your hosts file (/etc/hosts).

I don't know enough about this or your specific usage scenario and don't want to lead you astray so I won't say too much more, but I've got some other ideas...

Rob Ruder's picture

I appreciate you responding, Jeremy. I'm definitely feeling my way through this transition. The good news is that I seemed to have finally got it working. I think that I had the hostname changed... the installation gave me an error message when I tried 'hostname -f' but it would return the right host name ( when I typed in just 'hostname.'

I kept fiddling around with the configuration files in PostFix and finally I got a different error when I tested the email form and so I backed off one setting and the messages went through.  The following is what I ended up with in /etc/postfix/

alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myhostname =
mydomain =
mydestination = localdomain, localhost, localhost.localdomain, localhost
mailbox_size_limit = 0
recipient_delimiter = +
myorigin =
inet_interfaces = all

I had made these changes and restarted postfix multiple times over the last 3 hours, but finally they kicked in. I'm not sure what the final trick was, but I'm happy it is working.

Thanks again for your input.


Jeremy Davis's picture

But it sounds a bit strange. Obviously if it's working that's great, but personally I would be wondering about why 'hostname -f' is returning an error, and AFAIK 'hostname' should be returning your server name (ie www) - not an FQDN (ie But as I say if it's working for you you may wish to leave it at that. I would definitely keep those things in mind though if other strange behaviour occurs.

Add new comment