Why does SMTP mail submission get its own port 587, and how does a submission agent differ from the MTA on port 25?
answer
- two jobs: injecting mail versus transferring it
- RFC 6409, November 2011
- authenticate before MAIL is accepted
- 530 when no authentication is in force
basics
~20 sPort 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 sRFC 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
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.
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.
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.
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.