By Maria Smith
I have a Node.js app running on a DigitalOcean Droplet that sends transactional emails. The emails go out fine but a lot of them land in spam folders. I have been told I need to set up SPF, DKIM, and DMARC but I do not fully understand how the whole email delivery process works under the hood.
Can someone explain how SMTP actually works from sending to delivery, and what the most common reasons are for emails ending up in spam? I want to understand it properly before I start configuring DNS records.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hi there,
Good question and understanding how SMTP works before touching DNS records is the right approach.
If you want to see the full flow visually, this interactive SMTP flow simulator walks through exactly what happens from sender to inbox step by step.
The short version: your app connects to an SMTP server, which sends the email to the recipient’s mail server. That receiving server then checks a bunch of things before deciding whether to deliver to inbox or spam.
The three DNS records that matter most:
SPF tells receiving servers which IP addresses are allowed to send email for your domain. Without it, anyone can spoof your domain and receiving servers will not trust your emails.
DKIM adds a cryptographic signature to your emails that proves they were not tampered with in transit. Most providers generate this for you.
DMARC ties SPF and DKIM together and tells receiving servers what to do if either check fails.
One important thing to know: DigitalOcean blocks outbound SMTP ports by default on all new Droplets, so even if your code is correct you will not be able to send directly from the Droplet without requesting the block to be lifted. More context here: https://docs.digitalocean.com/support/why-is-smtp-blocked/
The easier path is using a dedicated SMTP service which handles IP reputation and deliverability for you. You could use something like SMTPfast or SendGrid for example.
Heya,
Rather than planning around that, route your app’s mail through a dedicated relay like SMTPFast, SendGrid, Mailgun, or Postmark over their HTTP API or a non-standard port. That sidesteps the block entirely and, just as importantly for your actual problem, hands deliverability, IP warmup, and sender reputation to infrastructure built for it, which matters more for spam placement than anything you can configure on a single Droplet’s IP.
Regards
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.
