Skip to content

Email

Email has a history that predates the web, and it remains one of the most widely used services on the internet.

How Email Works

To understand how email operates, consider how traditional mail works. If you're in Beijing and want to send a letter to a friend in Hong Kong, you write the letter, put it in an envelope, address it, and drop it off at a nearby post office. The letter travels through various postal systems until it reaches your friend's mailbox, where it awaits their retrieval.

Email follows a similar process, but at lightning speed. If your email address is me@163.com and your friend's is friend@sina.com, you would use a program like Outlook or Foxmail to send an email. These programs are known as Mail User Agents (MUA).

  1. Sending Email: The email goes from your MUA to a Mail Transfer Agent (MTA), which is the email service provider (like NetEase for 163.com). The MTA forwards the email to the recipient's service provider's MTA (in this case, Sina's MTA).

  2. Delivery: Upon reaching Sina's MTA, it then sends the email to the Mail Delivery Agent (MDA), where the email is stored until your friend retrieves it using their MUA.

Email Journey

The full journey of an email is:

Sender -> MUA -> MTA -> MTA -> MTA (multiple) -> MDA <- MUA <- Recipient

Sending and Receiving Emails

When you send an email, the MUA and MTA use the Simple Mail Transfer Protocol (SMTP). For receiving emails, two main protocols are used:

  • POP3 (Post Office Protocol version 3): Downloads emails from the server to the client.
  • IMAP (Internet Message Access Protocol version 4): Allows more interaction with the server, such as organizing emails without downloading them.

Configuration

To send emails, you must configure the SMTP server in your email client. For example, if using 163.com, you'd use smtp.163.com. You'll need to provide your email address and password for verification.

For receiving emails via POP3 or IMAP, similar credentials and server information are required. Note that many email providers require manual activation of SMTP and POP functionalities to allow access beyond web interfaces.

Setup

Before programming in Python to send and receive emails, ensure you have at least two email accounts from different providers (e.g., xxx@163.com, xxx@sina.com).

Remember, many providers have security settings that must be adjusted to allow SMTP and POP/IMAP access.

Email has loaded