Domain Name System – How to Fix Postfix Not Resolving MX Record

domain-name-systemfreebsdpostfix

Log

to=<x.y@example.com>, relay=none, delay=21311, delays=21301/0.04/10/0, dsn=4.4.3, status=deferred (Host or domain name not found. Name service error for name=localdomain type=MX: Host not found

OS: FreeBSD

When I run the following command on my postfix client, it does resolve. mail.p.example.com hosts our postfix server, which then relays emails to gmail smtp.

host -t MX p.example.com
p.example.com mail is handled by 10 host.p.example.com.

I compare my postfix config with a working config on another host and they're the same.

inet_protocols = ipv4
mynetworks_style = host
inet_interfaces = loopback-only
relayhost = $mydomain

There's more to the config than what I pasted above but nothing related to dns. smtp_host_lookup hasn't been set (default value = dns).

I do not have any resolv.conf files under /var/spool/postfix. Would appreciate any directions on how postfix resolves DNS records.

Best Answer

Aha, now the problem is obvious:

relayhost = $mydomain

You have configured Postfix to deliver all mail to $mydomain, which is set to localdomain.

Your narrative indicates you meant to be relaying mail to Gmail, so your relayhost should be set to the appropriate Google hostname for that purpose, e.g.:

 relayhost = [smtp-relay.gmail.com]:25

or

 relayhost = [smtp-relay.gmail.com]:587

and your smtp_sasl_password_maps should point to a file containing your Gmail credentials, if you are using SMTP authentication.

Related Topic