TurnKey Linux Virtual Appliance Library

SMTP in Turnkey LAMP

administrator_2'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 mx1.mailhop.org[] 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/main.cf), 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

I'm no expert in these things either...

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

Thanks for the input...

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 (www.catered4you.com) 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/main.cf:

alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myhostname = www.catered4you.com
mydomain = catered4you.com
mydestination = localdomain, localhost, localhost.localdomain, localhost
mailbox_size_limit = 0
recipient_delimiter = +
myorigin = catered4you.com
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

Glad you got it working

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 www.catered4u.com). 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.

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account, used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <p> <span> <div> <h1> <h2> <h3> <h4> <h5> <h6> <img> <map> <area> <hr> <br> <br /> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <em> <b> <u> <i> <strong> <font> <del> <ins> <sub> <sup> <quote> <blockquote> <pre> <address> <code> <cite> <strike> <caption>

More information about formatting options

Leave this field empty. It's part of a security mechanism.
(Dear spammers: moderators are notified of all new posts. Spam is deleted immediately)