The Electronic Mail and WWW Protocols

The Electronic Mail and WWW Protocols

1. The Electronic Mail System

An Overview of Electronic Mail

Electronic mail (email) is one of the most widely used communication services on the Internet, and it supports many formats, from plain text to images and attached files.

The System Structure

The user agent (UA):

  • Mail client: Outlook, Thunderbird, Foxmail
  • Web mail: Gmail, QQ Mail, 163 Mail
  • Mobile mail: the mail application on a phone

The mail server:

  • Sending server: an SMTP server
  • Receiving server: a POP3 or IMAP server
  • Relay server: a mail forwarding server

The mailbox:

  • Inbox: the mail that has arrived
  • Outbox: the mail waiting to be sent
  • Drafts: the mail that is not finished
  • Trash: the mail that has been deleted

The Mail Format and MIME

The structure of a message:

  • Header: the sender, the recipients, the subject, the date, and so on
  • Body: the content of the message
  • Attachments: the attached files

MIME (Multipurpose Internet Mail Extensions):

  • Text types: plain text, HTML text
  • Image types: JPEG, PNG, GIF
  • Audio types: MP3, WAV, MIDI
  • Video types: MP4, AVI, MOV
  • Application types: PDF, DOC, ZIP

The SMTP Protocol

Function: sending mail

How it works:

  1. The connection is established: the client connects to the SMTP server
  2. Authentication: the client presents a user name and password
  3. The mail is transferred: the client sends the content of the message
  4. The connection is closed: the connection is closed once the transfer is complete

Common commands:

  • HELO: the client identifies itself
  • AUTH: authentication
  • MAIL FROM: the sender’s address
  • RCPT TO: the recipient’s address
  • DATA: the mail data
  • QUIT: close the connection

Port number: 25 (plaintext), 587 (encrypted)

The POP3 Protocol

Function: receiving mail

How it works:

  1. The connection is established: the client connects to the POP3 server
  2. Authentication: the client presents a user name and password
  3. The mail is downloaded: the client downloads the messages
  4. The connection is closed: the connection is closed once the download is complete

Characteristics:

  • Simple: the protocol is simple and easy to implement
  • Offline: the mail is downloaded to the local machine
  • Deleted: the server deletes the mail after the download
  • Single device: suits use from a single device

Port number: 110 (plaintext), 995 (encrypted)

The IMAP Protocol

Function: receiving mail

How it works:

  1. The connection is established: the client connects to the IMAP server
  2. Authentication: the client presents a user name and password
  3. The mail is synchronised: the client and the server synchronise the mailbox
  4. The connection is kept: the connection state is maintained

Characteristics:

  • Online: the mail is stored on the server
  • Several devices: it supports synchronisation across devices
  • Folders: it supports managing folders of mail
  • Search: it supports searching the mailbox

Port number: 143 (plaintext), 993 (encrypted)

2. The WWW and HTTP

An Overview of the WWW

The WWW (World Wide Web) is a distributed hypermedia system built on the HTTP protocol.

The Structure of the WWW

Hypertext:

  • HTML: the Hypertext Markup Language
  • Links: the hyperlinks between pages
  • Multimedia: text, images, audio, and video

The browser:

  • Function: parses HTML and displays the page
  • Types: Chrome, Firefox, Safari, Edge
  • Extensions: support for various additional functions

The server:

  • Web server: Apache, Nginx, IIS
  • Application server: Tomcat, WebLogic, WebSphere
  • Database server: MySQL, Oracle, SQL Server

The HTTP Protocol

Basic concepts:

  • Connectionless: every request is handled independently
  • Stateless: no state is kept between requests
  • Request-response: the client requests, the server responds

HTTP methods:

  • GET: retrieve a resource
  • POST: submit data
  • HEAD: retrieve the header information of a resource
  • PUT: update a resource
  • DELETE: delete a resource
  • OPTIONS: retrieve the methods that are supported
  • TRACE: echo the request back

HTTP status codes:

  • 1xx: informational
  • 2xx: success (200 OK)
  • 3xx: redirection (301, 302)
  • 4xx: client error (404, 403)
  • 5xx: server error (500, 502)

The HTTP Request Format

GET /index.html HTTP/1.1
Host: www.example.com
User-Agent: Mozilla/5.0
Accept: text/html,application/xhtml+xml
Accept-Language: zh-CN,zh;q=0.9
Connection: keep-alive

The HTTP Response Format

HTTP/1.1 200 OK
Date: Mon, 23 May 2005 22:38:34 GMT
Server: Apache/1.3.3.7
Content-Type: text/html; charset=UTF-8
Content-Length: 138

<html>
<head>
<title>Example</title>
</head>
<body>
Hello World
</body>
</html>

The HTTPS Protocol

Security properties:

  • Encrypted transport: the traffic is encrypted with SSL/TLS
  • Authentication: the identity of the server is verified
  • Data integrity: tampering with the data is prevented

How it works:

  1. The handshake phase: the encryption parameters are negotiated
  2. The key exchange: a session key is generated
  3. The data transfer: the data is transferred in encrypted form

Port number: 443

3. Application Scenarios

Electronic Mail Applications

Personal communication:

  • Everyday correspondence
  • Handling work mail
  • Receiving notification mail

Enterprise use:

  • Internal corporate communication
  • Customer support
  • Sending marketing mail

Secure mail:

  • Encrypted mail transport
  • Digital signature verification
  • Mail archiving and management

WWW Applications

Information browsing:

  • Browsing news sites
  • Using search engines
  • Visiting social media

E-commerce:

  • Online shopping
  • Online banking
  • Online payment

Web applications:

  • Online office work
  • Cloud storage services
  • Online education

Exercises

Exercise 1

What are the respective roles of SMTP and POP3 in an electronic mail system?

smtppop3email protocols

Approach

Treat SMTP and POP3 as the two halves of the mail path: one pushes a message towards its destination, the other pulls a message back to the user. List the three responsibilities of each.

Steps

  1. State the three roles of SMTP.
  2. State the three roles of POP3.
  3. Close with the contrast between pushing and pulling.

Answer

The role of SMTP:

  1. Sending mail:

    • The client sends the mail to the SMTP server
    • The servers forward the mail to one another
    • The mail is made sure to reach the destination server
  2. Mail routing:

    • The mail is routed according to the recipient’s address
    • Mail relaying is supported
    • Mail forwarding is handled
  3. Authentication:

    • The identity of the sender is verified
    • Forged mail is prevented
    • Permission to send mail is controlled

The role of POP3:

  1. Receiving mail:

    • The client downloads the mail from the POP3 server
    • It obtains the list of messages
    • It downloads the content of the messages
  2. Mail management:

    • Messages are marked as read
    • Messages are deleted from the server
    • The state of the mailbox is managed
  3. Offline access:

    • The mail is downloaded to the local machine
    • It can be read offline
    • The storage used on the server is reduced

Exercise 2

What are the main characteristics of the HTTP protocol? Which HTTP methods are common?

httphttp methodsstateless protocol

Approach

Describe the five properties of HTTP first, since they explain how the protocol is put together, then list the seven methods with what each one does and whether it is idempotent.

Steps

  1. Describe the connectionless property.
  2. Describe the stateless property.
  3. Describe the request-response model.
  4. Describe the text-based property.
  5. Describe the extensible property.
  6. List the seven methods.

Answer

The main characteristics of the HTTP protocol:

  1. Connectionless:

    • Every request is handled independently
    • No connection state is maintained
    • The server consumes fewer resources
  2. Stateless:

    • No state is kept between requests
    • Every request stands on its own
    • The server scales out easily
  3. The request-response model:

    • The client sends a request
    • The server returns a response
    • A simple and clear interaction model
  4. Text-based:

    • The protocol messages are in text format
    • They are easy to debug and to understand
    • Many character encodings are supported
  5. Extensible:

    • Custom headers are supported
    • Many content types are supported
    • The protocol is easy to extend

The common HTTP methods:

  1. GET:

    • Retrieves a resource
    • The parameters are passed in the URL
    • An idempotent operation
  2. POST:

    • Submits data
    • The data is carried in the request body
    • A non-idempotent operation
  3. HEAD:

    • Retrieves the header information of a resource
    • The content of the resource is not returned
    • Used to check the state of a resource
  4. PUT:

    • Updates a resource
    • Replaces the resource entirely
    • An idempotent operation
  5. DELETE:

    • Deletes a resource
    • Deletes the specified resource
    • An idempotent operation
  6. OPTIONS:

    • Retrieves the methods that are supported
    • Checks the capabilities of the server
    • Used for the CORS preflight
  7. TRACE:

    • Echoes the request back
    • Used for debugging
    • Shows the path the request took

Glossary

TermAbbreviationExplanation
Simple Mail Transfer ProtocolSMTPThe protocol for sending mail (port 25)
Post Office Protocol version 3POP3The protocol for receiving mail (port 110)
Internet Message Access ProtocolIMAPThe protocol for receiving mail (port 143)
Multipurpose Internet Mail ExtensionsMIMEThe standard that extends the content of a message
User agentUAThe mail client software
Mail Transfer AgentMTAThe server that transfers mail
Mail Delivery AgentMDAThe server that delivers mail
Hypertext Transfer ProtocolHTTPThe protocol that transfers web pages (port 80)
HTTP SecureHTTPSHTTP with encryption (port 443)
World Wide WebWWWThe information system built on HTTP
Uniform Resource LocatorURLThe address of a resource
HyperText Markup LanguageHTMLThe language used to write web pages
Cascading Style SheetsCSSThe language used to style web pages
CookieCookieData that a site stores on the client
Session-The state of a user held on the server
Status code-The status of an HTTP response (such as 200, 404)
Proxy server-A server that forwards the traffic in between

Found an issue with this content?

Tell us what could be improved.