My emails wouldn’t send when I was working from home, giving me this message in /var/log/mail.log:
Nov 11 12:38:16 machinename postfix/smtp[20672]: CF5D6D41CE2: to=, relay=none, delay=14416, delays=14416/0.01/0.07/0, dsn=4.3.5, status=deferred (Host or domain name not found. Name service error for name=relay.example.com type=AAAA: Host not found)
It turned out I was telling postfix not to use DNS to resolve the domain name of my mail relay server. There were several postfix config options I needed to remove to make this work:
# Make sure all of these are commented out or removed! #default_transport = smtp #relay_transport = smtp #inet_protocols = ipv4 #smtp_host_lookup = native
The default values for these options are fine, but the ones shown above stop it working, so remove them or comment out with a # at the beginning of the line.
More at Postfix configuration parameters.
Seems like the issue is that Postfix creates jail before network stack fully initialized, so /var/spool/postfix/etc/resolv.conf doesn’t have any servers to use and that’s why it fails. I have this issue on my raspberry pi Ubuntu setup and don’t have it on other PC.
Thanks Alex, yes – something weird is going on because I still see similar problems sometimes even with this config, but if I specify my relayhost by IP instead of domain name it works fine.
In my case, there is a legacy config from CentOS.
“`
disable_dns_lookups = yes
“`
I use Ubuntu now, I have no idea how it worked in CentOS while it was set like this.