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 [email protected]
(Host or domain name not found. Name service error for name=smtp.gmail.com type=A: Host not found, try again)
[email protected]
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.
The problem is that Postfix checks /etc/resolv.conf
before the WiFi is connected. Therefore, /var/spool/etc/postfix/resolv.conf
stays empty after the boot and mails cannot be sent.
To solve the problem, I disabled postfix service:
sudo update-rc.d postfix disable
…and I wrote this script to wait the end of the Wi-Fi connection before to start Postfix (saved in /usr/local/bin/postfix_wifi.sh
):
#!/usr/bin/sh
host="smtp.gmail.com"
port=587
until nc $host $port -w 5
do
sleep 10
done
sudo service postfix start
exit 0
…and I added this line to /etc/rc.local
so that the script is run at boot:
/usr/local/bin/postfix_wifi.sh &
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments