DEV Community

Cover image for How an Email Travels Across the Network
Tahsin Abrar
Tahsin Abrar

Posted on

How an Email Travels Across the Network

You (the sender) want to email Sakib (the receiver). Think of your email as a parcel. The internet is the postal system. We’ll walk through the 5-layer TCP/IP model and watch this parcel travel.

Layers:

  1. Application
  2. Transport
  3. Network
  4. Data Link
  5. Physical

1) Application Layer “Write & Prepare the Parcel”

What happens:

  • You type the email and attach files.
  • The email client (MUA) prepares an SMTP message.
  • Attachments are wrapped using MIME (and often compressed or base64-encoded).
  • TLS (encryption) is planned so nobody can read the email on the wire.

Application Layer

Standard practices

  • Keep attachments small; many providers limit to ~20–25 MB. Prefer cloud links for big files.
  • Use UTF-8 for text.
  • Turn on TLS (STARTTLS or implicit TLS) so the path is encrypted.

Quick mental hook: “Write it, wrap it, lock it (TLS).”


2) Transport Layer “Cut Into Chunks & Number Them”

What happens:

  • The SMTP message may be bigger than what the network can send at once.
  • TCP splits it into segments (chunks), numbers each, and ensures delivery with ACKs.
  • A 3-way handshake (SYN, SYN-ACK, ACK) sets up the session.
  • Client uses an ephemeral port; server listens on a well-known port.

Ports (common)

  • Submission: 587 (SMTP with STARTTLS)
  • SMTP server to server: 25
  • IMAP over TLS: 993, POP3 over TLS: 995

Transport Layer

Standard practices

  • Submit mail on 587 with authentication and STARTTLS.
  • Don’t disable Nagle/algorithms etc. without reason; defaults are usually fine.
  • If sending very large data often, consider links instead of huge attachments.

Quick mental hook: “Cut, number, handshake.”


3) Network Layer “Put IP Addresses On Every Chunk”

What happens:

  • Each TCP segment is wrapped in an IP packet with source IP and destination IP.
  • Routers use the destination IP to forward packets hop by hop to Sakib’s mail server.
  • TTL (time to live) prevents endless looping.

Network Layer

Standard practices

  • Make sure DNS and MX records for your domain are correct (delivery depends on it).
  • Your client is often behind NAT; your router translates private IP → public IP.

Quick mental hook: “Address every page with IP.”


4) Data Link Layer “Wrap For The Local Hop (MAC & Frame)”

What happens:

  • On each local link (your Wi-Fi/Ethernet, your ISP’s next hop), IP packets are wrapped into frames with MAC addresses.
  • ARP resolves “which MAC is next?” for local delivery.
  • Each hop unwraps/re-wraps frames as the packet moves through.

Data Link Layer

Standard practices

  • On unstable Wi-Fi, expect retries. For important sends, prefer a stable link (Ethernet).
  • Keep drivers/firmware updated for fewer link-level drops.

Quick mental hook: “Local delivery uses MAC.”


5) Physical Layer “Turn Frames Into Signals”

What happens:

  • Frames become electrical/optical/radio signals (Ethernet, fiber, Wi-Fi).
  • Bits travel over cables/air between devices.

Standard practices

  • Use good cables/APs. Poor cables and congested Wi-Fi = packet loss → TCP retransmissions → slow email sends.
  • For offices, wire critical machines.

Quick mental hook: “Bits ride wires or waves.”


On Sakib’s Side “Unwrap & Reassemble”

Reverse happens:

  • Physical → Data Link → Network → Transport → Application.
  • TCP reorders segments, fills gaps, and hands the complete message to SMTP on the server.
  • The Mail Delivery Agent stores it in Sakib’s mailbox.
  • Sakib opens her client (IMAP/POP3) and reads it.

Physical Layer

Top comments (0)