So you have setup your own mail server on Digital Ocean. Everything works great, but for some reason all of your outgoing mail to Gmail’s addresses ends up in the Spam folder. What to do?
1. Check your SPF record
SPF is a validation system to detect spoofing and needs to be setup in your DNS records. Fire up the DNS console of your droplet and make sure that you have it setup properly by adding a “TXT” record with the following content: “v=spf1 mx -all”. This assumes you have a proper MX record setup already. Check the SPF syntax documentation here for more information.
Don’t bother to setup DKIM, it doesn’t seem to matter for the purpose of getting your mail delivered to Gmail.
2. Check that your public IP is not blacklisted
If everything seems in place, but your e-mails are still being categorized as Spam, you might want to spawn a new droplet and get a new public ip for your mail server. Google seems to hold a private blacklist of IPs from which e-mails are automatically flagged as spam. Some of these IPs are used by Digital Ocean and there’s nothing you can do to whitelist them. Your only option is to spawn another droplet, get assigned a new public IP, and try again.
Fortunately this process is painless. Simply take a snapshot of your current droplet, spawn a new one and choose to restore your snapshot. Then update your DNS records and try to send an e-mail from the new IP. I got lucky and the second droplet I spawned worked for me.
Did this help you? Let me know in the comments.0