Postfix - Name service error for name=mailrelay.cool.com type=MX: Host not found

 

The following postfix error occurs in /var/log/mail after attempting to send a mail.

node01 postfix/master[29890]: reload configuration
node01 postfix/pickup[25736]: 9D7A419DC: uid=0 from=
node01 postfix/cleanup[25754]: 9D7A419DC: message-id=<4D079A0B.mailJV011XXAU@node01.cool.com>
node01 postfix/qmgr[25737]: 9D7A419DC: from=<root@node01.cool.com>, size=451, nrcpt=1 (queue active)
node01 postfix/smtp[25756]: 9D7A419DC: to=<john.smith@greatcompany.co.uk>, 
relay=none, delay=0, status=deferred (Host or domain name not found. 
Name service error for name=mailrelay.cool.com type=MX: Host not found, try again)

/etc/postfix/main.cf had the correct relayhost entry for the mail server such as

relayhost = mailrelay.goodcompany.com

However DNS was not configured on the mail client as there was no DNS server configured on the network and therefore the mail client was using /etc/hosts for name resolution.

The errors were caused by the following line in main.cf

disable_dns_lookups = no

Change this setting to yes and reload the configuration by using the following command

postfix reload

Now try to send a mail, it should hopefully reach its destination now, or at least the above errors should have gone.