I am using Raspbian and the Postfix (version 2.9.6) service seems to be automatically run when I boot, but if I want to send a mail, the email stays in the queue:
$ mailq
26CB72201F 443 Sat Sep 19 19:44:17 user@mail.example.com
(Host or domain name not found. Name service error for name=smtp.gmail.com type=A: Host not found, try again)
someone@gmail.com
If I restart the service (sudo service postfix restart
) then emails work until the next boot.
Why? What is the difference?
During the Postfix installation I chose the configuration “Internet with smarthost” but then I followed a tutorial for …Internet Site” to finish the configuration so this might be the problem(?) I just want to send emails.
UPDATE: The problem might be that that Postfix is run before the Wi-Fi is connected.
Best Answer
Shorter answer.
With a “Host not found, try again.” it could mean that your server is having DNS resolution issues, or Postfix itself is having DNS resolution issues. But that is the core of what has to be cleaned up.
As for how to clear it up, your question doesn’t provide enough details on your base OS or setup to give a succinct answer. You seem to be running Ubuntu/Debian if you are running
sudo service postfix restart
, but what other details can you provide?Longer answer.
Possibly connected to
resolv.conf
mysteriously disappearing.Based on the error:
It seems like you are using Gmail’s SMTP servers for outgoing mail. Unsure what your base OS is, but based on this answer on Ubuntu Forums this seems to be an issue with a missing
resolv.conf
on reboot; bold emphasis is mine:The suggested temporary solution is to copy the main OS
resolv.conf
to Postfix’s directory:This isn’t a permanent fix it seems but at least it’s something to check out.
Possibly connected to
inet_protocols
settings.Also this answer on Server Fault explains a similar situation which focuses on IPv6 support. Pretty sure your issue is not IPv6-related since the error is about a “type=A” record which is IPv4 and for IPv6 it would be “type=AAAA.” But that said, it might worth experimenting with adjusting the
inet_protocols
setting in your Postfix config file. Here is what the official Postfix documentation explains:Assuming you are on an Ubuntu/Debian setup open up the config here:
And find—or set the value—to the
inet_protocols
line to be either this:Or be this:
Then restart the Postfix service—or the whole server—and see if that clears things up: