Symptoms
-
Email messages are not delivered when Plesk on Digital Ocean is used.
-
The Digital Ocean (DO) server has enabled IPv6 and IPv4 addresses and Postfix.
-
The Plesk firewall and the ip6tables are configured to allow outgoing traffic via IPv6:
ACCEPT tcp ::/0 ::/0 tcp dpt:25
-
Records in /var/log/maillog are timing out:
# egrep “Connection timed out” /var/log/maillog | tail
Feb 13 12:12:36 example postfix/smtp[16848]: connect to aspmx.l.google.com[2001:db8:f61:a1ff:0:0:0:80]:25: Connection timed out -
The warning below may appear after the Daily Maintenance task execution in Tools & Settings > Mail Server Settings:
PLESK_WARN: You cannot send emails from Plesk because outbound connections on TCP port 25 is blocked. Check the firewall settings or contact your hosting provider. If you are sure that the ports are already open, Plesk can recheck them. Start the recheck.
Cause
At Digital Ocean, SMTP traffic over IPv6 is blocked at the network level: https://www.digitalocean.com/docs/networking/ipv6/.
Resolution
As a workaround, the precedence over the getaddrinfo calls can be modified by editing the gai.conf file to prioritize IPv4.
Connect to the server via SSH and apply one of the following solutions:
For Debian/Ubuntu
-
Open the file
/etc/gai.conf
using any text editor, for example, Vi. -
Remove the comment (#) from the following line and save the changes:
# precedence ::ffff:0:0/96 100
For RHEL/Centos
-
Create the file
/etc/gai.conf
:# vi /etc/gai.conf
-
Add the line below there:
precedence ::ffff:0:0/96 100