Postfix: Host not found, try again
If you configured Postfix to relay all outgoing mail through a smarthost and that host does not have an MX record — or does not have one anymore — the queue starts filling up and the log fills with deferrals:
Jul 14 12:45:39 myhostname postfix/smtp[2349]: 74FBF30501:
to=<recipient@example.org> relay=none, delay=3944,
status=deferred (Name service error for name=smtp.example.com
type=MX: Host not found, try again)
The Postfix FAQ is right about the cause, which still leaves the question of what to do about it. By default Postfix treats relayhost as a mail domain and looks up its MX record. If there is none, the lookup fails and the mail stays in the queue.
The fix is to tell Postfix that the value is a host name and not a domain to be resolved via MX. That is what square brackets mean in Postfix configuration. Open the main configuration file:
editor /etc/postfix/main.cf
and change
relayhost = smtp.example.com:587
to
relayhost = [smtp.example.com]:587
Then reload the configuration:
systemctl reload postfix
Postfix now resolves the A and AAAA records of the host directly and stops looking for an MX record. The same notation works everywhere a next hop is given, including the right-hand side of a transport_maps or relay_host entry — and it is the form you want for a smarthost in any case, since it also saves a needless DNS lookup.
/etc/init.d/postfix reload. On a current distribution use systemctl reload postfix, or the distribution-independent postfix reload. The bracket notation itself is unchanged.