06 – Electronic Mail: SMTP, IMAP, POP3 and Mail Security
Course: ICT Basic course · Level: introductory Book: Kurose & Ross, 9th ed., chapter 2.3 (electronic mail in the Internet)
Learning goals
After this article you can:
- describe the parts of the Internet e-mail system: user agents, mail servers and protocols;
- explain how SMTP delivers mail from server to server, step by step;
- explain the difference between push (SMTP) and pull (IMAP, POP3) protocols;
- explain the role of DNS MX records in mail delivery;
- explain why e-mail is easy to fake and how SPF, DKIM and DMARC help.
1. The e-mail system
1 2 3 4 | |
| Component | Role | Examples |
|---|---|---|
| User agent (MUA) | read, write, send mail | Outlook, Apple Mail, Thunderbird, Gmail app, webmail in the browser |
| Mail server (MTA) | stores mailboxes, queues outgoing messages, delivers to other servers | Microsoft Exchange Online, Gmail, Postfix, Exim |
| SMTP | pushes mail: client → server and server → server | |
| IMAP / POP3 / HTTPS | pulls mail from the mailbox to the user |
E-mail is asynchronous: Bob doesn't have to be online when Alice sends a message. His mail server keeps it.
2. SMTP – Simple Mail Transfer Protocol
- One of the oldest Internet protocols (RFC 821, 1982; current version RFC 5321).
- Runs over TCP.
- Push protocol: the sending server opens a connection to the receiving server and pushes the message.
- Text-based commands; originally only 7-bit ASCII. Attachments and non-English characters are encoded with MIME (e.g. Base64).
2.1 Which port?
| Port | Use |
|---|---|
| 25 | server ↔ server (MTA to MTA). Many ISPs block outgoing port 25 from home connections to stop spam from infected PCs |
| 587 | submission: your mail client → your own mail server, with STARTTLS and login |
| 465 | submission over implicit TLS (deprecated for years, but re-standardised in RFC 8314 and now recommended) |
2.2 An SMTP dialogue
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | |
Note the two levels of addresses:
- the envelope (MAIL FROM, RCPT TO), which servers use for delivery;
- the header (From:, To:) that you see in your mail client. Nothing in plain SMTP checks that these match, so this is how spoofing works.
2.3 How does the sending server find the receiving server?
Via DNS: it looks up the MX record (Mail eXchanger) of the recipient's domain.
1 2 | |
So mail for @hva.nl is handled by Microsoft 365 (Exchange Online).
(MX records have a priority: lower number = preferred server.)
3. Mail access protocols: getting your mail
| Protocol | Port (encrypted) | How it works | Today |
|---|---|---|---|
| POP3 | 995 (110 plain) | download and (usually) delete from the server | Legacy: still supported, but not suitable when you read mail on several devices |
| IMAP | 993 (143 plain) | mail stays on the server; folders and read/unread status are synchronised across devices | standard for mail apps |
| HTTPS (webmail) | 443 | the browser or app talks to the mail server via a web API | most common: Gmail, Outlook on the web |
| Exchange ActiveSync / Microsoft Graph, JMAP | 443 | modern APIs for mobile apps | ActiveSync is being phased out; JMAP (RFC 8620/8621) is a modern open alternative |
Still in use? POP3 still exists, especially in older setups and for archiving, but most people use IMAP or webmail/apps. Microsoft and Google have switched off "basic authentication" (username + password) for IMAP/POP/SMTP and require OAuth 2.0 / modern authentication.
4. Try it yourself
- Look up the mail servers of a few domains:
1 2 3 4
dig MX hva.nl +short dig MX gmail.com +short dig TXT hva.nl +short # look for v=spf1 ... dig TXT _dmarc.hva.nl +short # DMARC policy - Open an e-mail in your mail client and look at the full headers ("Show original" in Gmail, "View message source" in Outlook). Find the
Received:lines (the route the mail took) and theAuthentication-Results:line (SPF/DKIM/DMARC results). - Test a mail domain at https://www.internet.nl/ (mail test). Which modern standards are used?
- Send a mail to the address given at https://www.mail-tester.com/ and read the score report.
Check your understanding
- Which protocol pushes mail, and which protocols pull mail?
- Why does SMTP use DNS MX records?
- What is the difference between the envelope sender and the
From:header? - What is the main difference between POP3 and IMAP?
- Why do ISPs block outgoing port 25?
References
Book
- Kurose & Ross, 9th ed., chapter 2.3 (Electronic mail in the Internet)
Videos
- Jim Kurose's video lectures, chapter 2 (e-mail) – https://gaia.cs.umass.edu/kurose_ross/lectures.php
- Professor Messer – CompTIA Network+ N10-009 course (ports and protocols, e-mail) – https://www.youtube.com/playlist?list=PLG49S3nxzAnl_tQe3kvnmeMid0mjF8Le8
Articles and standards
- RFC 5321 – SMTP – https://www.rfc-editor.org/rfc/rfc5321
- RFC 9051 – IMAP4rev2 – https://www.rfc-editor.org/rfc/rfc9051
- RFC 8314 – Use of TLS for e-mail submission and access – https://www.rfc-editor.org/rfc/rfc8314
- RFC 7489 – DMARC – https://www.rfc-editor.org/rfc/rfc7489
- DMARC.org – overview and resources – https://dmarc.org/
Cyber Security
Why is this important for cyber security?
- E-mail is the number one entry point for attacks. Phishing (fake mails that steal passwords), malicious attachments, and Business E-mail Compromise (a fake "CEO" or supplier asks to transfer money) cause enormous damage every year. Many ransomware attacks start with one e-mail.
- SMTP was never designed to be secure. Without extra measures, anyone can send a mail with
From: ceo@yourcompany.nl(spoofing), and mail between servers may travel unencrypted. - Mailboxes contain sensitive data (personal data, invoices, password-reset links). A hacked mailbox often gives access to many other accounts.
What can you do to make it safe?
As a domain owner / administrator: e-mail authentication
| Standard | What it does | DNS record (example) |
|---|---|---|
| SPF – Sender Policy Framework | lists which servers may send mail for your domain | example.nl TXT "v=spf1 include:spf.protection.outlook.com -all" |
| DKIM – DomainKeys Identified Mail | the sending server signs each mail with a private key; receivers check the signature with the public key from DNS | selector1._domainkey.example.nl TXT "v=DKIM1; k=rsa; p=MIIB..." |
| DMARC | tells receivers what to do when SPF/DKIM fail (none, quarantine, reject) and where to send reports |
_dmarc.example.nl TXT "v=DMARC1; p=reject; rua=mailto:dmarc@example.nl" |
Since 2024, Google and Yahoo require SPF, DKIM and DMARC for bulk senders. Microsoft has added similar requirements for Outlook.com.
Encryption between servers - STARTTLS upgrades an SMTP connection to TLS, but by default it is opportunistic: an attacker can strip it. - MTA-STS (via HTTPS) and DANE (via DNSSEC) force servers to use TLS with a valid certificate. The Dutch government requires these standards ("pas-toe-of-leg-uit" list of Forum Standaardisatie).
Access to mailboxes - Use only encrypted ports (993, 995, 465/587 with TLS, 443). - Multi-factor authentication (MFA) on every mailbox; disable legacy/basic authentication.
As a user - Check the real sender address and links (hover before clicking); be suspicious of urgency ("pay today!"). - Never send passwords or verification codes by e-mail. Verify payment requests via another channel (phone). - Report phishing (in NL: forward to valse-email@fraudehelpdesk.nl, or use your organisation's report button). - For end-to-end encryption of the content: S/MIME or OpenPGP (e.g. Proton Mail uses OpenPGP).
Extra references
- Internet.nl – mail test (SPF, DKIM, DMARC, STARTTLS, DANE) – https://www.internet.nl/
- Forum Standaardisatie – mandatory open standards (incl. DMARC, DANE) – https://www.forumstandaardisatie.nl/
- Fraudehelpdesk (NL) – https://www.fraudehelpdesk.nl/
- Google's e-mail sender guidelines – https://support.google.com/a/answer/81126
- NCSC-NL factsheets on e-mail security – https://www.ncsc.nl/