Email works by breaking a message into packets that travel from your mail client to your outgoing mail server, then across the internet to the recipient's incoming mail server, where it waits in a mailbox until the recipient's client retrieves it. The process relies on a chain of protocols—SMTP for sending and relaying, and either IMAP or POP for retrieval—plus DNS lookups to find the right servers.
The Core Protocols: SMTP, IMAP, and POP
Three protocols do most of the work. SMTP (Simple Mail Transfer Protocol) handles sending and relaying mail between servers. IMAP (Internet Message Access Protocol) and POP (Post Office Protocol) handle retrieval from the recipient's mailbox. SMTP is a push protocol: the sender's server pushes the message toward the destination. IMAP and POP are pull protocols: the recipient's client pulls messages from the server.
SMTP uses TCP port 25 for server-to-server relay, while mail clients typically submit outgoing mail on port 587 (with authentication) or port 465 (implicit TLS). IMAP usually listens on port 143 or 993 (TLS), and POP on port 110 or 995 (TLS). These port numbers matter because firewalls and mail servers use them to distinguish submission from relay.
Step by Step: From Compose to Inbox
Here is the typical path of an email, simplified but accurate for most setups:
- Compose and submit. You write a message in a mail client (Outlook, Apple Mail, Gmail's web interface). The client connects to your outgoing SMTP server, authenticates, and hands over the message.
- Sender authentication and queuing. The outgoing server checks that you are allowed to send (credentials, sometimes IP reputation). It adds a Message-ID header, timestamps, and possibly DKIM signatures, then places the message in a queue.
- DNS lookup for the recipient domain. The server extracts the domain from the recipient address (the part after @) and queries DNS for MX records (Mail Exchanger records). MX records list the hostnames of servers willing to accept mail for that domain, with priority numbers.
- Relay to the destination MX. The sending server opens an SMTP connection to the highest-priority MX host and transmits the message. If that host is unreachable, it tries the next priority.
- Recipient server acceptance. The destination server may run checks: spam filtering, virus scanning, SPF/DKIM/DMARC validation, greylisting. If accepted, it responds with a 250 OK code. If rejected, it returns a 4xx (temporary) or 5xx (permanent) code.
- Local delivery. The accepted message is passed to a mail delivery agent (MDA), which files it into the recipient's mailbox—often a Maildir or mbox file on disk, or a database in cloud systems.
- Retrieval. The recipient's mail client connects via IMAP or POP, authenticates, and downloads or syncs the message. With IMAP, the message typically stays on the server; with POP, it is often downloaded and removed.
Each hop between servers is a separate SMTP transaction. A message might pass through several relays—for example, a corporate outbound gateway, then the recipient's cloud security gateway, then the final mailbox server—before it lands.
What MX Records and DNS Do
DNS is the internet's directory. For email, the key record is the MX record. A domain like example.com publishes MX records such as:
- 10 mail1.example.com
- 20 mail2.example.com
Lower numbers mean higher priority. A sending server tries mail1 first; if it fails, it tries mail2. MX records must point to hostnames, not IP addresses, and those hostnames need A or AAAA records. Some domains also publish a null MX record (a single MX with a dot) to declare that they accept no email.
Other DNS records support authentication. SPF (Sender Policy Framework) is a TXT record listing which servers are allowed to send mail for the domain. DKIM (DomainKeys Identified Mail) publishes a public key so recipients can verify a cryptographic signature added to outgoing messages. DMARC ties SPF and DKIM together and tells receivers what to do when checks fail.
Headers, Envelope, and the Hidden Machinery
An email has two layers: the envelope and the content. The envelope is what SMTP uses to route the message—the MAIL FROM and RCPT TO commands. The content includes headers (From, To, Subject, Date, Message-ID, Received) and the body. The From header you see in your client is not necessarily the envelope sender; this distinction matters for bounce handling and spam filtering.
Each server that handles the message adds a Received header at the top. Reading these headers from bottom to top traces the message's path. Delays between Received timestamps can reveal where a message was held up. Message-ID is supposed to be globally unique and is generated by the originating system.
Common Delivery Problems and What They Mean
When email fails, the error usually comes as an SMTP status code or a bounce message. Common issues include:
- 550 or 554 rejections. Permanent failures: the mailbox does not exist, the server blocks your IP, or the message failed a policy check.
- 450 or 451 temporary failures. The server is busy, greylisting is in effect, or a DNS lookup failed. The sending server retries later, often for several days.
- SPF/DKIM/DMARC failures. The message may be marked as spam or rejected outright. Fix by aligning DNS records with the actual sending servers.
- Full mailbox. The recipient's quota is exceeded; the server returns a temporary error until space is freed.
- Blacklisting. The sending IP or domain appears on a blocklist. Remedy involves fixing the cause (often compromised accounts or spam complaints) and requesting delisting.
Misconception: many people believe email is instant and direct. In reality, it is store-and-forward. Each server may queue the message, and retries can take hours or days. A message that appears sent can still be sitting in a queue.
Security and Authentication in Practice
Plain SMTP has no built-in encryption or sender verification. Two additions fill the gap. TLS (often called STARTTLS) encrypts the connection between servers and between client and server, protecting contents in transit. Authentication via SPF, DKIM, and DMARC lets receiving servers judge whether a message really came from the domain it claims.
End-to-end encryption is separate: PGP or S/MIME encrypts the message body so only the recipient can read it, but the headers (sender, recipient, subject) usually remain visible to relays. Without end-to-end encryption, any server in the chain could theoretically read the message, which is why sensitive content should be encrypted before sending.
Frequently Asked Questions
Does email go directly from my computer to the recipient's computer?
No. Your client sends to an outgoing SMTP server, which relays to the recipient's incoming server. The recipient's client later retrieves it. Direct computer-to-computer delivery is possible in theory but rare because of spam controls, dynamic IP addresses, and reliability concerns.
What happens if the recipient's server is down?
The sending server queues the message and retries, typically every few minutes to hours, for a period set by the sender's policy—often two to five days. If delivery still fails, the sender receives a bounce message with the reason.
Can I recall an email after sending?
Generally no. Once the message leaves your server, you have no control over it. Some corporate systems offer recall within the same organization, but it is not a standard internet feature and often fails if the recipient has already read the message.
Why do some emails arrive in spam?
Receiving servers score messages using many signals: authentication results, sender reputation, content patterns, and user complaints. A legitimate message can land in spam if its domain lacks proper SPF/DKIM/DMARC records or if the sending IP has a poor reputation.
Is email encrypted?
Often only in transit. TLS protects the connection between servers and between client and server, but the message is decrypted at each hop. End-to-end encryption with PGP or S/MIME is needed to keep the body private from relays.
What is the difference between IMAP and POP?
IMAP keeps messages on the server and syncs folders and read status across devices. POP downloads messages to one device and often deletes them from the server. IMAP is better for multiple devices; POP suits a single-computer setup with limited storage.