oscarmlage oscarmlage

Postfix resolving /etc/hosts entries

Written by oscarmlage on

Most of times when you are setting up a mail server you need to test that all is going fine. Well, in fact tests should happen *after* the server is configured. Talking about an integral email solution (send + receive), some kind of tests come to my mind:

Nothing so complicate... unless your server is not a DNS MX endpoint. I mean if the server is not in "production" state (because we're configuring it) there shouldn't be any entry pointing to it, so how could we test the incoming email?.

We need to tweak other mail server (the one from which we're going to send the test email) to say: "hey friend, the email you're going to send is not for the real MX entry in DNS for example.com, please deliver it to this other IP". Thanks Wu for the idea. May you think how? of course, /etc/hosts:

12.12.12.12    mail.example.com

But, if the email server you're tweaking is Postfix you'll have to change a bit the configuration, because it's not taking care of /etc/hosts by default, you need to change a couple of directives (lmtp_host_lookup, smtp_host_lookup) to say: "hey friend, take in account /etc/hosts before to go to dns stuff". Here we go, in main.cf:

lmtp_host_lookup = native
smtp_host_lookup = native

Now restart the postfix and write an email (echo "testing" | main account@example.com) while tailing logs to ensure all is happening in a right way.