A situation
You add your work email to a new phone. The setup screen asks for an “incoming server” and an “outgoing server”, each with its own port. Why two? Because sending mail and reading mail are two different jobs, done by different protocols.
What they are
- SMTP (Simple Mail Transfer Protocol) sends mail. Your email app uses it to hand a message to your mail server, and mail servers use it to pass the message to each other.
- POP3 (Post Office Protocol version 3) downloads mail from the server to one device, and usually deletes it from the server (many apps can be set to keep a copy).
- IMAP (Internet Message Access Protocol) lets you read mail that stays on the server, so every device sees the same folders and the same read or unread marks.
💡 In simple terms: SMTP is the postal service that carries letters between post offices. POP3 empties your mailbox and takes everything home. IMAP lets you read your letters while they stay in the mailbox, so they look the same whichever device you use.
Follow one email
Alice (alice@example.com) writes to Bob (bob@example.net). To find Bob's mail server, Alice's server looks up the MX record (mail exchanger) for example.net in DNS.
- 1. 1. Submit. Alice's email app logs in and sends the message to her own server with SMTP on port 587.
- 2. 2. Find the destination. Her server asks DNS for the MX record of example.net and gets mx.example.net.
- 3. 3. Relay. The message moves from server to server with SMTP on port 25.
- 4. 4. Read. Bob's phone reads the message from his server with IMAP over TLS.
What SMTP says
SMTP is a text conversation made of short commands and three-digit reply codes. Codes starting with 2 mean OK, 3 means “go on”, 4 means a temporary error and 5 means a permanent error.
Real servers usually send STARTTLS after EHLO, so the rest of the conversation is encrypted.
Why the ports differ
Most of these protocols have a plain port and an encrypted one. Port 25 is used for server-to-server relay. Users submit mail on port 587 (or 465) and must log in, which stops strangers from using the server to send spam.
| Protocol | Job | Plain port | Encrypted port |
|---|---|---|---|
| SMTP | Server-to-server relay | 25 | 25 with STARTTLS |
| SMTP submission | App sends to its own server | 587 with STARTTLS | 465 (TLS from the start) |
| POP3 | Download to one device | 110 | 995 |
| IMAP | Read and sync on the server | 143 | 993 |
All of them run on TCP. POP3 made sense when most people had only one computer. Today, most people read mail on both a phone and a laptop, so IMAP is the usual choice.
How to verify it
Check which servers receive mail for a domain by looking up its MX records from any computer:
nslookup -type=mx example.netList the mail servers for example.net, with their preference numbers.
Example output, shortened and written for this lesson:
example.net mail exchanger = 10 mx.example.net. example.net mail exchanger = 20 mx2.example.net.
What to look for: each mail exchanger line names one mail server for the domain. The number before the name is the preference: the lower number (10, mx.example.net) is tried first, and mx2.example.net (20) is the backup. You can run the same check with the MX Lookup tool.
Check yourself
A user at one company emails a user at another company. Which protocol moves the message from the first company's mail server to the second company's?
You read mail on a phone and a laptop and want both to show the same folders. Which protocol fits?
Your mail server must deliver a message to bob@example.net. Which DNS record does it look up to find where to send it?