skip to content

SMTP

SMTP moves mail as a plain-text command dialog over TCP, relayed hop by hop via MX records. Interviewers probe it because its trust-anything design explains every later fix bolted onto email.

on this pageshow

explore

questions

29

Why does SMTP mail submission get its own port 587, and how does a submission agent differ from the MTA on port 25?

level: juniorimportance: must knowfreq 62%

answer

  1. two jobs: injecting mail versus transferring it
  2. RFC 6409, November 2011
  3. authenticate before MAIL is accepted
  4. 530 when no authentication is in force

basics

~20 s

Port 587 is RFC 6409's submission port: its submission agent accepts new mail only from authenticated users and may complete the message. Port 25 carries relay between MTAs, takes unauthenticated senders, and should accept mail only for domains it serves.

solid answer

~50 s

RFC 6409 (November 2011) separates *submission*, a mail client or device handing a new message to its own organisation, from *relay*, one MTA passing a finished message to the next. Mail arriving on port 587 is defined to be a submission, and the mail submission agent (MSA) MUST by default refuse `MAIL` with `530` until the session has authenticated with SMTP AUTH (RFC 4954) or is otherwise authorised, for example from a protected subnetwork. Because it knows the user, the MSA can check which envelope senders a login may use, must ensure every envelope domain is fully qualified, and should add a missing `Message-ID`. Port 25 is where other organisations' MTAs deliver to your MX: it cannot demand credentials from the whole internet, so it stays unauthenticated and accepts mail only for the domains it serves. Many networks also block outbound port 25 from end-user machines, which is one more reason clients submit on 587.

go deeper

for a junior

Recall the two roles: 587 is where your own users and devices hand in new mail after logging in, and 25 is where other organisations' servers deliver mail to your domain.

for a middle

Explain RFC 6409's strengths: authentication is a MUST by default with 530, fully qualifying envelope domains is a MUST, and completing the message or checking sender rights are SHOULD or MAY.

for a senior

Show how you keep the policies apart on a real server: authentication offered only on the submission listener, relay permitted only to trusted networks and authenticated users, and sender addresses bound to logins.

for a principal

Frame it as an exposure decision: every extra listener that accepts credentials or relays widens the attack surface, so decide which devices may submit, from where, and who owns the exceptions.

## Two jobs that once shared one port SMTP (RFC 5321) was designed as a **transfer** protocol: a way for one **message transfer agent (MTA)** to hand a finished message to the next until it reaches the recipient's domain. Over time the same protocol also became the way a **mail user agent** (a mail client, a scanner, an application) introduces a *new* message into the system. That second job is **submission**, and the server that does it is a **mail submission agent (MSA)**. The two jobs need opposite policies. An MX that receives mail for `example.com` must accept connections from any MTA on the internet, because any of them may carry legitimate mail for its users. A submission server must do the reverse: refuse everybody except its own users, because it will relay their mail *anywhere*. **RFC 6409** (November 2011, obsoleting RFC 4409) gives submission its own port, **587**, so that each listener can run the policy that fits it. RFC 6409 says plainly that messages received on 587 "are defined to be submissions". ## What RFC 6409 requires of a submission agent RFC 6409 sorts its rules by strength, and the strength matters when you read a configuration: 1. **MUST, by default, require authentication.** Section 4.3: the MSA issues an error to `MAIL` if the session is not authenticated with SMTP AUTH (RFC 4954), unless it has independently established authorisation, such as the client being inside a protected subnetwork. The reply is `530` (RFC 4954 pairs it with `5.7.0`, "Authentication required"). 2. **MUST ensure envelope domains are fully qualified** (section 4.2), rejecting improper domain references with `554`; it SHOULD reject, not guess at, an incomplete multi-level domain. 3. **SHOULD** reject illegal address syntax, log client errors, and answer every command, even `DATA`, in under two minutes (section 5). 4. **MAY** refuse a `MAIL FROM` address the authenticated user is not entitled to use, with `550` and `5.7.1` (section 6.1). 5. **MAY complete the message** (section 8): add `Date` if it is missing, add or replace `Sender`, and it **SHOULD** add a missing or invalid `Message-ID`. | | Submission (MSA) | Relay (MTA) | |---|---|---| | Usual port | 587 | 25 | | Who connects | your own users and devices | any MTA on the internet | | Authentication | required by default | not expected | | Destinations accepted | any, for an authorised user | only the domains it serves | | May alter the message | yes, to complete it | only add trace fields such as `Received` | RFC 6409 also allows a site to run submission on port 25 by designating some hosts as MSAs and others as MTAs, so the port is a convention the RFC reserves, not a law of physics. In practice many networks block outbound 25 from end-user machines precisely because infected hosts used it to send spam directly, so clients use 587. Implicit TLS on port 465, which RFC 8314 prefers for submission, is covered with STARTTLS and transport security. ## Why port 25 stays open to everyone An inbound MX cannot ask the rest of the internet for a password: there is no shared account between your server and every other organisation's MTA. So port 25 stays unauthenticated, and its protection is a different rule: **accept mail only for the domains you receive for**. RFC 6409 section 3.2 gives exactly this example, an MTA that rejects any `RCPT` not referencing local users beside an MSA that rejects any submission not from an authorised user. A server that accepts anyone's mail for anyone's domain is an open relay; that failure and how routing works afterwards are covered with relaying and MX routing. ## The reference MTA's version of the split Postfix, the reference MTA, keeps the two policies apart in the same way: - Postfix's `smtpd_sasl_auth_enable` defaults to `no`: the SMTP server offers no authentication until you turn it on, usually only for the submission service on port 587. - Postfix's `smtpd_relay_restrictions` defaults to `permit_mynetworks, permit_sasl_authenticated, defer_unauth_destination`: trusted networks and authenticated users may relay, everyone else may only deliver to local destinations. - Postfix's `smtpd_sender_login_maps` with `reject_sender_login_mismatch` ties envelope sender addresses to the login names that own them, the RFC 6409 section 6.1 check in practice. ## Common confusions - **587 is not "25 with encryption".** It is a different role. Encryption is negotiated separately on either port. - **SMTP AUTH identifies a user to their own MSA.** It says nothing to the final receiver; the receiver's checks of the sending domain are the job of sender authentication, a different subject. - **Authentication is not authorisation.** A logged-in user may still be refused a sender address that belongs to a colleague, if the MSA enforces submission rights. - **A framework's SMTP mailer is just a submission client.** Whatever the library, it speaks this same protocol to an MSA on 587.

  • Is it ever acceptable to accept submissions on port 25?
    RFC 6409 section 3.1 says a site MAY use port 25 for submission by designating some hosts as MSAs and others as MTAs. The cost is that one listener must now tell submissions from relay by host, and many access networks block outbound 25 from end-user machines anyway, so a separate 587 listener is the cleaner design.
  • Once a user has authenticated, what stops them sending with a colleague's envelope address?
    Nothing in SMTP AUTH itself. RFC 6409 section 6.1 lets the MSA refuse a `MAIL FROM` the authenticated user is not entitled to, with `550` and `5.7.1`. In Postfix that is `smtpd_sender_login_maps` plus `reject_sender_login_mismatch`, which binds each envelope sender to the login names that own it.

  • Port 587 is just the encrypted version of port 25.
  • Our MX on port 25 should require SMTP AUTH from every sender to stop spam.
  • Any server listening on 587 will relay mail for whoever connects.
  • SMTP AUTH proves to the recipient's server that the From header is genuine.
  • A submission server must pass the message on exactly as the client wrote it.
open as a page

In SMTP, what do a reply code's first and second digits mean, and how does an enhanced status code such as 5.1.1 refine them?

level: juniorimportance: must knowfreq 60%

basics

~20 s

An SMTP reply's first digit gives the outcome: 2 done, 3 send more, 4 temporary failure worth retrying, 5 permanent failure. The second digit names the category, and an enhanced code like 5.1.1 adds class, subject and detail.

open as a page

In SMTP, how does the envelope sender given in MAIL FROM differ from the From header a recipient sees?

level: juniorimportance: must knowfreq 68%

basics

~20 s

MAIL FROM is the envelope reverse-path, sent in the SMTP dialog and used for bounces; From is the author's address inside the message content. RFC 5321 requires no relationship between them, so they can differ.

open as a page

What is the difference between an open SMTP relay and a mail server that relays only for authenticated clients or trusted networks?

level: juniorimportance: must knowfreq 58%

basics

~20 s

An open relay accepts mail from any client for any destination. A correctly run MTA relays to outside domains only for authenticated clients or trusted networks, and accepts everything else only for domains it serves.

open as a page

Why does opportunistic STARTTLS between mail servers not guarantee an encrypted, authenticated hop, and what can a domain do about it?

level: juniorimportance: must knowfreq 50%

basics

~20 s

The STARTTLS offer arrives in cleartext, so an on-path party can remove it and the sender, by design, carries on unencrypted; opportunistic senders also accept any certificate. MTA-STS, DANE or per-destination mandatory TLS make the hop required and authenticated.

open as a page

In SMTP, how does STARTTLS on ports 25 and 587 differ from implicit TLS on port 465, and which does RFC 8314 prefer for submission?

level: juniorimportance: must knowfreq 55%

basics

~20 s

STARTTLS (RFC 3207) begins in cleartext and upgrades the same connection; implicit TLS on port 465 handshakes before any SMTP is spoken. RFC 8314 (2018) prefers implicit TLS for submission, while relay between servers stays on port 25 with STARTTLS.

open as a page

When a receiving SMTP server replies 4xx instead of 5xx, what does the sending MTA do, and when is a bounce sent?

level: middleimportance: must knowfreq 52%

basics

~20 s

A 4xx is temporary: the sending MTA queues and retries, RFC 5321 suggesting 30 minutes or more between tries and 4-5 days before giving up. A 5xx, or giving up, triggers a bounce sent from the null sender <>.

open as a page

In a hand-driven SMTP test of your staging MTA on port 25, which commands run from EHLO to QUIT, and how does DATA end?

level: middleimportance: must knowfreq 44%

basics

~20 s

After the 220 greeting the client sends EHLO, MAIL FROM, one RCPT TO per recipient and DATA, then the message ended by a line holding only a dot, then QUIT. Replies: 250 to each step, 354 after DATA, 221 after QUIT.

open as a page

In an Authentication-Results header, what do the authserv-id, the method=result pairs, smtp.mailfrom, header.d and header.from each tell you?

level: middleimportance: must knowfreq 42%

basics

~20 s

The authserv-id names the receiving service that ran the checks; each method=result pair gives one check's outcome; smtp.mailfrom is the envelope domain SPF evaluated, header.d the DKIM signing domain and header.from the From domain DMARC evaluated.

open as a page

How do you read a message's Received header chain, and which Received entries can a receiving organisation actually trust?

level: middleimportance: must knowfreq 48%

basics

~20 s

Each SMTP hop prepends a Received field, so the chain reads bottom-up with the oldest hop last. Trust only the entries your own servers added, and in your edge server's entry, the connecting IP address it took from the TCP connection.

open as a page

In SMTP AUTH (RFC 4954), how does PLAIN differ from a token mechanism such as OAUTHBEARER, and why are both kept inside TLS?

level: middleimportance: should knowfreq 34%

basics

~20 s

PLAIN (RFC 4616) sends the username and reusable password, merely base64-encoded; OAUTHBEARER (RFC 7628) sends a short-lived OAuth 2.0 bearer token instead. Either can be replayed by whoever reads the session, so both belong only inside TLS.

open as a page

In an SMTP EHLO response, what do the PIPELINING, SIZE and CHUNKING keywords advertise, and how does each change the dialog?

level: middleimportance: should knowfreq 18%

basics

~20 s

PIPELINING (RFC 2920) lets a client batch commands without waiting for each reply; SIZE (RFC 1870) advertises the largest accepted message and lets MAIL FROM declare one; CHUNKING (RFC 3030) adds BDAT, sending counted chunks instead of DATA.

open as a page

Why can a delivered message's Return-Path show a sending service's bounce domain while its From header shows the brand's domain?

level: middleimportance: should knowfreq 34%

basics

~20 s

Return-Path is written by the server making final delivery, copied from the envelope MAIL FROM. A sending service puts its own bounce address in MAIL FROM so failures return to it, while From keeps the brand.

open as a page

When a recipient domain publishes no MX record, where does an RFC 5321 sending MTA deliver, and when must it report an error instead?

level: middleimportance: should knowfreq 32%

basics

~20 s

Under RFC 5321 section 5.1, an empty MX answer makes the domain its own implicit MX at preference 0, so the sender uses its A or AAAA addresses; a non-existent domain is an error and a temporary DNS failure is queued.

open as a page

How does an MTA-STS policy (RFC 8461) tell sending MTAs to require authenticated TLS, and what do its enforce, testing and none modes change?

level: middleimportance: should knowfreq 32%

basics

~20 s

A domain publishes a _mta-sts TXT record (v=STSv1 and an id) and serves a policy over HTTPS from mta-sts.<domain>/.well-known/mta-sts.txt. Under enforce, senders deliver only to listed MX hosts presenting valid certificates; testing only reports; none withdraws the policy.

open as a page

What is SMTP backscatter, and how should a receiving mail server be configured so that it never sends backscatter itself?

level: seniorimportance: should knowfreq 24%

basics

~20 s

Backscatter is bounces, auto-replies and filter notices sent to innocent addresses forged as spam's envelope sender. A receiver avoids causing it by refusing during the SMTP session, validating recipients at RCPT, and not notifying senders about spam or malware.

open as a page

A newsletter's mail is deferred for hours at one large mailbox provider while other domains accept it; how do you tell greylisting, a DNS blocklist and a reputation rate limit apart?

level: seniorimportance: should knowfreq 30%

basics

~20 s

Read the deferral text and retry history. Greylisting defers a new sender once, then accepts its retry; a DNS blocklist hit usually names the list and persists; a reputation limit cites the provider's own code and eases only as complaints fall.

open as a page

What was the 2023 SMTP smuggling flaw involving bare line feeds, how do you tell whether your MTA is exposed, and what fixed it?

level: seniorimportance: should knowfreq 21%

basics

~20 s

SMTP smuggling (CVE-2023-51764, -51765, -51766): one mail service relayed a non-standard end-of-data sequence built on bare line feeds, and the next took it as the real end, accepting a second message. Patched MTAs end data only at CR LF . CR LF.

open as a page

A security review finds your internet-facing MX answers SMTP VRFY truthfully; how do you confirm the exposure, and what closes it across VRFY, EXPN and RCPT?

level: seniorimportance: should knowfreq 27%

basics

~20 s

Compare your MX's VRFY replies for a real and an unknown mailbox. Close it by disabling VRFY and EXPN or limiting them to authenticated users, answering 252 as RFC 5321 7.3 requires, and rate-limiting RCPT probing.

open as a page

Which Authentication-Results fields on a delivered message should your mail filters trust, and how should your border handle look-alike fields arriving from outside?

level: seniorimportance: should knowfreq 22%

basics

~20 s

Trust only Authentication-Results fields carrying your own authserv-id that your boundary added. RFC 8601 requires a border MTA to delete arriving fields that claim your authserv-id, and lets it strip all external ones or keep an allowlist.

open as a page

After pointing a domain's MX records at an inbound filtering service, why can some mail still reach the origin mail server unfiltered, and how do you close that path?

level: seniorimportance: should knowfreq 26%

basics

~20 s

MX records only tell senders where to deliver. Mail still reaches the origin through a leftover backup MX entry when the filter's hosts fail, or by direct connection. Remove the origin from MX and accept port 25 only from the filter.

open as a page

An SMTP TLS report (RFC 8460) for a partner domain whose MTA-STS policy is in testing shows certificate-host-mismatch on one MX; what happened to that mail, and what must change before enforce?

level: seniorimportance: should knowfreq 16%

basics

~20 s

Senders found that MX's certificate lacked its MX host name, but testing mode let them deliver anyway, most likely over unauthenticated TLS. Before enforce, the MX needs a certificate naming its host, or senders will refuse it and queue the mail.

open as a page

Moving off password-based SMTP AUTH to Exchange Online before Microsoft's deadlines: how would you plan it for a multifunction printer and a line-of-business app?

level: principalimportance: should knowfreq 20%

basics

~20 s

Inventory every client still submitting with a password and move each to token-based SMTP AUTH or a relay you control before end-December 2026, when Microsoft's 27 January 2026 timeline turns Basic SMTP AUTH off by default for existing tenants.

open as a page

Should a fleet of application servers deliver outbound mail directly to recipients' MX hosts or through a central smart host, and what does each choice cost?

level: principalimportance: should knowfreq 22%

basics

~20 s

Usually through a smart host: one relay owns queuing, retries, signing, rate limits and sending reputation, and application servers need no port 25 egress. The cost is a critical dependency that must be redundant and must never relay for strangers.

open as a page

For SMTP between your bank and three partner domains that must never travel in cleartext, how do you choose between bilateral mandatory TLS, MTA-STS enforce and DANE in each direction?

level: principalimportance: should knowfreq 18%

basics

~20 s

Outbound, set a mandatory, authenticated TLS policy per partner in your own MTA. Inbound, publish MTA-STS enforce, DANE if you can run DNSSEC, and TLS reporting, and have each partner pin mandatory TLS toward you.

open as a page

What does an RFC 7505 null MX record tell sending MTAs about a parked domain that must accept no mail, and how do they react?

level: middleimportance: nice to knowfreq 16%

basics

~20 s

A null MX is a single MX record with preference 0 and exchange ".", declaring that the domain accepts no mail. Senders fail such recipients at once, with reply 556 and status 5.1.10 per RFC 7505, instead of queuing and retrying.

open as a page

For DANE on SMTP (RFC 7672), where does a receiving domain publish TLSA records, and why are DANE-EE(3) and DANE-TA(2) the usages to use?

level: seniorimportance: nice to knowfreq 12%

basics

~20 s

TLSA records sit at _25._tcp.<MX host> in a DNSSEC-signed zone. DANE-EE(3) pins the server's own key and skips name and expiry checks; DANE-TA(2) pins an issuing CA and keeps name checks. Port-25 records SHOULD NOT use PKIX-TA(0) or PKIX-EE(1).

open as a page

For an internet-facing MX you run, would you reject or normalise SMTP lines that end in a bare LF, and which clients would you exempt?

level: principalimportance: nice to knowfreq 9%

basics

~20 s

Both require the standard CR LF . CR LF end of data, which closes SMTP smuggling. Normalising keeps mixed-line-ending senders working; rejecting also refuses scripts, web applications and health checks. Measure first; exempt only trusted internal clients.

open as a page

Display-name spoofing passes SPF, DKIM and DMARC for the sender's own domain; which controls would you set as policy to expose it, and at what cost?

level: principalimportance: nice to knowfreq 16%

basics

~20 s

The display name is an unauthenticated phrase in From; RFC 9989 puts it out of DMARC's scope. Expose it by showing the full address and tagging external mail, accepting banner fatigue, false positives and broken DKIM on modified copies.

open as a page