Slow Email Sending on DigitalOcean

After migrating a server to DigitalOcean, I had noticed that sending emails to Gmail was extremely slow for no apparent reason. DigitalOcean has decided to block outbound SMTP over IPv6. I can only assume this is to prevent spam since you can practically add an infinite number of IPv6 addresses to your droplet.

The simplest solution is to “prefer” IPv4 connections over IPv6 by editing /etc/gai.conf.

Uncomment #precedence ::ffff:0:0/96 100 and save the file. Sending email will now be much faster.

1
2
3
4
#
# For sites which prefer IPv4 connections change the last line to
#
#precedence ::ffff:0:0/96 100