Skip to content
Tutorials Center
My learning

Topics

Lesson 34 of 55 ยท Networks and the Internet

Email, the Cloud and Everyday Online Services

See how email travels with SMTP and IMAP, what the cloud really is, how SaaS and IaaS differ, and how caching and CDNs make streaming and websites fast.

Most of what people do on a computer today happens through a handful of online services: sending email, watching video, editing a document that is "in the cloud", backing up photos. They feel like magic, but each one is built from the pieces you have already met: programs, files, networks, names and addresses. Once you see the parts, services stop being mysterious and start being something you can choose, compare and troubleshoot.

This lesson explains how email moves from one person to another, what "the cloud" actually means, the main kinds of cloud service, and why caching and content delivery networks make video and web pages arrive quickly. It builds on Networking Basics, The Internet, IP Addresses and DNS and How the Web Works.

How email travels

Email is older than the web, and it is built from two separate jobs: sending and reading. Each job has its own protocol, a shared agreement about how two programs talk.

  • SMTP (Simple Mail Transfer Protocol) moves a message forward. Your mail program hands the message to your provider's outgoing server, and that server hands it to the recipient's provider.
  • IMAP (Internet Message Access Protocol) lets you read and organize mail that stays stored on the server. Because the messages live there, your phone, laptop and web browser all show the same inbox, folders and "read" marks. Its older cousin POP3 downloads mail to one device and usually removes it from the server.

Here is the journey of one message from [email protected] to [email protected]:

flowchart LR
  A["Ana's mail app"] -->|"SMTP"| B["home.example<br/>outgoing server"]
  B -->|"DNS asks: where is<br/>work.example's mail server?"| D["DNS (MX record)"]
  B -->|"SMTP"| C["work.example<br/>incoming server"]
  C --> M["Ben's mailbox<br/>(stored on server)"]
  M -->|"IMAP"| E["Ben's phone and laptop"]

The sender's server uses DNS to find the recipient's mail server, then delivers by SMTP; Ben reads the stored mailbox by IMAP.

The address after the @ is looked up in DNS. A special record type, the MX record (mail exchanger), names the servers that accept mail for that domain. If the first server is down, the sender tries the next one and keeps retrying for days before giving up and returning an error message called a bounce.

Three facts are worth remembering:

  1. Plain email is not private by default. A message may pass through several servers, and unless connections are encrypted (modern providers encrypt server-to-server links with TLS when both sides support it) and the message itself is end-to-end encrypted, those servers can read it. Treat email like a postcard unless you know otherwise.
  2. The "From" line is easy to fake. The protocol was designed in a more trusting time. Providers add checks (named SPF, DKIM and DMARC) to detect forgeries, but they are not perfect, which is why phishing works.
  3. Attachments are copied, not linked. A 20 MB attachment sent to ten people is stored ten times, and large files may be rejected by size limits. Sharing a link to a cloud file avoids both problems.

The stand-in below models the idea: a tiny "internet" with two mail servers, a DNS table of MX records, SMTP-style delivery and an IMAP-style mailbox with read flags. It is not real SMTP (there is no network conversation of commands and replies), but the roles of the pieces match.

JS A tiny mail system: SMTP delivery and IMAP reading

Press Run (or Ctrl + Enter) to see the console output here.

No output.

What "the cloud" means

"The cloud" is a friendly name for computers owned by someone else, reached over the internet, that you rent or use as a service. There is no cloud without physical machines: they sit in huge buildings called data centers, with fast networks, backup power and cooling. What makes it "cloud" is how you use them: on demand, over the network, usually paying for what you use, and without needing to know which machine does the work.

Compared with keeping things on your own computer ("local"), the cloud has real trade-offs:

Local Cloud
Access Only on that device From any device with internet
Works offline Yes Often limited or not at all
Backup and repair Your job The provider's job (but check)
Cost Pay once for hardware Pay over time (subscription or usage)
Control and privacy You hold the data The provider holds it, under its rules
Capacity Fixed by what you bought Grows or shrinks quickly

Neither is always better. Many people use both: files stored locally and synced to the cloud, as covered in Files, Folders and Staying Organized.

SaaS, PaaS and IaaS

Cloud services are often described by how much of the "stack" the provider manages for you. The more the provider manages, the less you need to know and the less you can customize.

  • SaaS (Software as a Service): a finished application you use in a browser or app, such as webmail, an online word processor or a video call service. You manage only your own data and settings.
  • PaaS (Platform as a Service): a ready environment where developers deploy their own program and the provider runs the operating system and runtime.
  • IaaS (Infrastructure as a Service): you rent raw building blocks, such as virtual machines, storage and networks. You install and manage the operating system and software yourself.
flowchart TB
  subgraph You["Layers you manage"]
    direction TB
    S1["SaaS: your data and settings"]
    S2["PaaS: your data, settings and your program"]
    S3["IaaS: all of that plus the OS and runtime"]
  end
  P["Provider always manages: building, power, network, physical servers"]
  S1 --> P
  S2 --> P
  S3 --> P

Moving from SaaS toward IaaS, you take on more layers; the provider always keeps the physical machines.

A virtual machine (VM) is a software-made computer running inside a real one; one physical server can host many VMs, which is how providers can rent small slices quickly.

Streaming, caching and CDNs

Watching a video does not download a whole file first. Streaming sends the video in small pieces, and your player keeps a few seconds of buffer ahead of what you are watching. Services also store each video at several quality levels and switch between them automatically (adaptive streaming) when your connection speeds up or slows down. That is why a picture can suddenly turn blurry for a moment and then sharpen.

If every viewer in the world fetched each popular video from one data center, that site would be overloaded and far-away viewers would suffer high latency. The answer is caching: keep a copy of data close to where it is needed, so the slow, distant source is asked as rarely as possible. You met this idea inside the computer in Memory: RAM, Cache and the Memory Hierarchy; on the internet it appears at several levels:

  • your browser cache stores images and scripts you recently loaded;
  • your DNS resolver remembers answers for a while;
  • a CDN (content delivery network) runs many servers around the world, called edge servers, and each keeps copies of popular files. Your request goes to a nearby edge. If the edge has the file (a cache hit), it answers immediately; if not (a cache miss), it fetches the file from the origin server, keeps a copy and sends it on.

A cached copy can go out of date, so each stored item has a TTL (time to live): after that many seconds it is considered stale and must be fetched again. A long TTL means fewer origin requests but a longer wait before changes appear; a short TTL means fresher content at higher cost. That is why a website change sometimes does not show up for a while.

JS A CDN edge cache with TTL

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Privacy trade-offs

Many online services are free because the provider earns money some other way, often by showing advertising based on what it learns about you. Even paid services keep records. Questions worth asking before you store something in a service:

  • Who can read it? The provider's staff, automated systems, courts or governments in the country where the data center sits? Only services with end-to-end encryption are designed so that even the provider cannot read the content.
  • Where does it live and for how long? Deleting a file from your view does not always remove every copy at once.
  • What happens if the account is closed or hacked? Strong sign-in protection matters here; see Passwords, Hashing and Encryption.
  • Can you get your data out? Export tools prevent being locked in.

The cloud is also not a backup by itself: a synced folder faithfully copies a deletion or a ransomware-encrypted file to every device. See Backups and Data Recovery.

What is real here and what is a stand-in? SMTP, IMAP, MX records, TTLs, edge servers and cache hits and misses are real concepts. The mailbox and the edge cache above are tiny models in JavaScript: real mail servers talk over network sockets with authentication and encryption, and real CDNs choose edges using DNS or routing tricks and honor cache headers sent by the origin.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Which protocol moves an email message from one mail server to the next?

    SMTP sends messages forward between servers. IMAP is used by your mail program to read mail stored on the server.
  2. 2. Why do your phone and laptop show the same inbox when you use IMAP?

    With IMAP the mailbox lives on the server, including read marks and folders, so every device sees the same state.
  3. 3. A company runs its own program on a rented virtual machine and installs the operating system itself. Which kind of service is that?

    Renting raw infrastructure such as virtual machines is IaaS. You manage everything from the operating system upward.
  4. 4. What does a CDN edge server do on a cache miss?

    A miss means the edge has no fresh copy. It asks the origin once, stores the result for the TTL and serves later visitors from the copy.
  5. 5. A site owner updates a picture but visitors still see the old one for a while. What is the most likely reason?

    Cached copies are served until they expire, so changes can take a while to appear unless the cache is purged.

Summary

  • Email is sent with SMTP, found through DNS MX records, stored on a server and read with IMAP, so all your devices share one mailbox.
  • Plain email is like a postcard: the sender address can be forged and content is not private unless encrypted end to end.
  • The cloud is other people's computers used over the internet, on demand; it trades control and offline access for convenience and capacity.
  • SaaS is a finished app, PaaS is a place to run your program, IaaS is raw infrastructure; the provider always manages the physical machines.
  • Streaming sends small pieces and adapts quality; caching and CDNs keep copies near users, with a TTL deciding how long a copy counts as fresh.
  • Ask who can read your data, where it lives, and how you can get it back out; the cloud does not replace backups.

Next, learn how to protect your accounts and data: Passwords, Hashing and Encryption.