# Q2(a) · SMTP phases

Subject: Computer Networks

Exam: TEE

Reader: https://deep-learning-study-room.vercel.app/cn/#tee/papers/paper-2023-final/q2a

Canonical: https://deep-learning-study-room.vercel.app/read/cn/tee/papers/paper-2023-final--q2a/

Actual paper; 100 marks attempted. Current-syllabus alignment is stated per question.

### Q2(a). Explain the working of Simple Mail Transfer Protocol in sending email messages. Briefly explain the three phases of mail transfer. [10 marks]

### Answer

**Simple Mail Transfer Protocol (SMTP)** transfers email from a sending client/server to a receiving mail server using a reliable transport, normally TCP. It is a push/store-and-forward transfer protocol. User agents compose/read mail; mail-transfer agents relay it, consulting DNS MX records to find recipient-domain mail servers.

Swipe across the diagram to read its labels ↔

![SMTP: envelope, message and completion](https://deep-learning-study-room.vercel.app/cn/fig/tee-smtp.c6f99877c4.svg)

Diagram: SMTP: envelope, message and completion. Labels: SMTP: envelope, message and completion | SMTP: envelope, message and completion | SMTP sender | Receiving server | 220 greeting | EHLO sender.example | 250 capabilities | MAIL FROM:<sender@example.com> | RCPT TO:<receiver@example.org> | DATA (after successful envelope replies) | 354 start mail input | Headers + blank line + body + dot line | 250 accepted; then QUIT / server 221 | SMTP submits/relays. Inbox reading uses IMAP/POP or webmail. | Envelope MAIL/RCPT differs from visible From/To headers.

Submission/relay use SMTP; reading an inbox uses a separate access protocol.

| Phase | Typical exchange | Purpose |
| --- | --- | --- |
| Connection and greeting | Server 220; client EHLO (HELO for basic SMTP); server 250 capabilities | Identify peers and learn supported extensions |
| Envelope transfer | MAIL FROM:<sender>; RCPT TO:<recipient>; 250 replies | Declare return path and one or more delivery recipients |
| Message transfer | DATA; server 354; headers + blank line + body; single dot line; server 250 | Transmit the message after server permission; completion reply accepts responsibility |
| Termination | QUIT; server 221 | Close the SMTP session cleanly |

## Message flow and important details

1. The sender’s user agent submits mail to its configured submission service. Server-to-server SMTP relay commonly uses TCP port 25; message submission commonly uses 587, often with authentication and TLS policy.
2. The sending server resolves the recipient domain’s MX records, connects to an appropriate mail server and carries out the SMTP exchange.
3. MAIL FROM and RCPT TO are the **envelope**; visible From/To headers inside DATA are message content and can differ. Multiple RCPT TO commands can name several recipients.
4. A line containing only a dot ends DATA. A content line beginning with a dot is dot-stuffed for transparency and unstuffed by the receiver.
5. A temporary 4xx failure can lead the sending server to queue and retry; a permanent 5xx failure normally rejects that operation. One successful handoff is not proof that a human read the message.
6. The recipient reads stored mail using an access protocol such as IMAP/POP3 or webmail. SMTP is not the mailbox-retrieval protocol.

#### Practical example

A message addressed to two recipients can send two RCPT TO commands before one DATA body. The SMTP envelope controls delivery even if the visible header lists a mailing-list name.

**Yaad rakho:** SMTP send/relay; inbox read IMAP/POP/webmail.

### The three phases requested in the paper

| Phase | Commands / replies | Meaning |
| --- | --- | --- |
| 1. Connection establishment | TCP connection; 220 greeting; EHLO/HELO; 250 reply | Open the connection and identify the SMTP peers |
| 2. Mail transfer | MAIL FROM, RCPT TO, DATA; 354; message; single dot; 250 | Transfer the envelope and then the message content |
| 3. Connection termination | QUIT; 221; close TCP | Finish the SMTP session |

Envelope transfer and message-body transfer are substeps of the single mail-transfer phase. Thus the more detailed table above still fits the standard three-phase description.
