Sub topic 1
From Your Server to the Recipient's Mailbox Provider
Prerequisites
This chapter assumes you know three things:
- Basic email sending: a sender, a recipient, and an ESP (email service provider) or your own SMTP server.
- DNS records, especially TXT records.
- The difference between transactional email (receipts, password resets) and marketing email (newsletters, promotions).
The path of a message
Every placement decision starts with the route a message takes. Your application does not deliver mail directly to a person. It hands the message to a mail transfer agent (MTA), which is the software that moves mail between servers. The MTA can be your own server or one run by your ESP.
- The application submits the message to the sending MTA.
- The MTA reads the recipient's domain and looks up its MX records in DNS. An MX record names the servers that accept mail for that domain.
- The MTA opens an SMTP connection (usually on port 25) to the highest-priority MX host.
- The two servers exchange SMTP commands, and the message is transferred.
- The receiving provider accepts or rejects it. If it accepts, it sorts the message into the inbox or the spam folder.
What the receiver sees
You can reproduce the first steps by hand. The lookup shows where mail for a domain goes:
dig +short MX example.orgA simplified SMTP conversation looks like this:
S: 220 mx.example.org ESMTP ready
C: EHLO mail.example.com
S: 250 mx.example.org at your service
C: MAIL FROM:<[email protected]>
S: 250 OK
C: RCPT TO:<[email protected]>
S: 250 OK
C: DATA
S: 354 Send message, end with a lone dot
C: From: News <[email protected]>
C: To: [email protected]
C: Subject: Welcome
C:
C: Hello!
C: .
S: 250 Queued as 7F3A91
C: QUIT
S: 221 ByeBefore it sees any content, the receiver already knows several identifiers:
| Identifier | Where it comes from | Why it matters |
|---|---|---|
| Connecting IP address | The TCP connection | The first thing checked, and hard to hide |
| EHLO hostname | The EHLO command | Should resolve in DNS and match the IP |
| Envelope sender | MAIL FROM (the Return-Path) | Where bounces go, and what SPF checks |
| Header From | The From header | What the recipient sees, and what DMARC checks |
| Message content | DATA | Checked last |
Later chapters explain how reputation attaches to these identifiers. For now, note that the decision is spread across the whole conversation.
Common errors
- Treating "250 accepted" as "delivered to the inbox." The 250 reply after DATA means the provider took responsibility for the message. It can still place the message in spam, and your logs will not show that.
- Treating every failure as final. A 4xx reply is temporary, so the MTA should retry. A 5xx reply is permanent, so retrying only hurts your reputation.
- Expecting content to be the only factor. A receiver can refuse the connection or the recipient before it reads a single header. When this happens, changing the subject line does nothing.
- Letting the identities disagree. The EHLO hostname, the envelope sender domain, and the header From domain should belong to the same organization. A mismatch looks like spoofing.
Exercise
Your server logs show "250 Queued" for a message, but the recipient says it never reached their inbox. Name one explanation consistent with that log line, and say what you could not conclude from it.
Show answer
The provider accepted the message and then filtered it into the spam folder (or quarantined it). A 250 reply means only that the message was accepted for processing, so you cannot conclude it reached the inbox.