What is SMTP? How email gets sent and delivered
The protocol that carries a message from your outbox to the recipient's mail server.
What SMTP does
SMTP stands for Simple Mail Transfer Protocol. It is how email is sent: from your mail app to your provider, and from your provider's server to the recipient's server. It dates back to RFC 821 in 1982, and the current specification is RFC 5321 (2008).
SMTP only pushes mail forward. It does not let you read your inbox. That job belongs to IMAP or POP3, which is why every mail account has an incoming server and a separate outgoing (SMTP) server.
Modern SMTP is usually called ESMTP (extended SMTP). A client that opens with EHLO instead of the original HELO gets a list of extensions the server supports, such as STARTTLS for encryption, AUTH for signing in and SIZE for the largest message it accepts.
A real SMTP conversation
Like IMAP, SMTP is a text protocol. The client sends commands and the server replies with three-digit codes. Here is a simplified delivery from one server to another:
S: 220 mx.example.net ESMTP ready
C: EHLO mail.example.com
S: 250-mx.example.net
S: 250-STARTTLS
S: 250 SIZE 52428800
C: MAIL FROM:<alice@example.com>
S: 250 OK
C: RCPT TO:<bob@example.net>
S: 250 OK
C: DATA
S: 354 End data with <CR><LF>.<CR><LF>
C: From: Alice <alice@example.com>
C: To: Bob <bob@example.net>
C: Subject: Lunch on Thursday?
C:
C: Are you free at noon?
C: .
S: 250 OK queued as 4F2A1C
C: QUIT
S: 221 ByeThe envelope and the letter
Notice that the sender appears twice. MAIL FROM and RCPT TO are the envelope: they tell servers where the message comes from and where to deliver it. The From: and To: lines after DATA are the headers you see in your mail app. They do not have to match, which is how mailing lists, BCC and, unfortunately, spoofing all work.
The envelope sender becomes the Return-Path header on delivery, and it is where bounce messages go. SPF checks this address, while DMARC ties the check back to the visible From address.
Submission, relay and ports
When your mail app sends a message, it uses submission: it connects to your provider's SMTP server, signs in, and hands over the message. This happens on port 587 (plain connection upgraded with STARTTLS) or port 465 (TLS from the start). Gmail's server, for example, is smtp.gmail.com on either port.
Your provider then relays the message. It looks up the MX (mail exchanger) record of the recipient's domain in DNS and connects to that server on port 25. Port 25 is for server-to-server traffic, and many home internet providers block it for ordinary computers to cut down on spam.
Reply codes tell the sender what happened. Codes starting with 2 mean success, 4 means a temporary problem (the sender will retry, often for several days), and 5 means a permanent failure, which produces a bounce message such as 550 No such user.
Questions
- Should I use port 465 or 587?
- Either works if your provider supports it. Port 465 encrypts from the first byte, which RFC 8314 now recommends. Port 587 starts in plain text and upgrades with STARTTLS. Use whatever your provider lists.
- Why does my outgoing server need a password?
- Without sign-in, anyone could use the server to send mail in your name. Requiring authentication on submission is what stops providers from becoming open relays for spam.
In Bloop.email
When you send from Bloop.email, your Mac hands the message to your provider's SMTP server directly (or through Microsoft's sign-in for Outlook). It does not pass through a Bloop server.
See the features