Reading — step 1 of 5
Read
~1 min readSMTP Basics
The SMTP Conversation
A typical SMTP exchange:
S: 220 mail.example.com ESMTP ready
C: EHLO client.example.com
S: 250-mail.example.com Hello
S: 250-SIZE 10485760
S: 250-PIPELINING
S: 250-STARTTLS
S: 250 AUTH PLAIN LOGIN
C: MAIL FROM:<[email protected]>
S: 250 OK
C: RCPT TO:<[email protected]>
S: 250 OK
C: RCPT TO:<[email protected]>
S: 250 OK
C: DATA
S: 354 Start mail input; end with <CRLF>.<CRLF>
C: From: [email protected]
C: To: [email protected]
C: Subject: Hello
C:
C: Hi Bob.
C: .
S: 250 Message accepted (queued as ABC123)
C: QUIT
S: 221 Bye
Each command starts a verb. Each response starts with a 3-digit code:
- 2xx: success.
- 3xx: more input needed (e.g., 354 after DATA).
- 4xx: temporary failure (try again).
- 5xx: permanent failure.
Multi-line responses use - (continuation) on intermediate lines, space on the last.
Commands:
- HELO: identify client (legacy).
- EHLO: identify + ask for extensions (modern, RFC 1869).
- MAIL FROM: who's sending.
- RCPT TO: who's receiving (multiple allowed).
- DATA: start the message body.
- STARTTLS: upgrade to TLS.
- AUTH: authenticate.
- RSET: reset session state.
- QUIT: end session.
Message body terminated by line containing only .. Lines starting with . in the body are dot-stuffed (. doubled to avoid premature termination).
Idempotency: SMTP doesn't retry within a session. If the connection drops mid-DATA, the receiving server discards. Sender must retry from scratch (with backoff).
Discussion
Ask a question, share an insight, or help someone who’s stuck.
Sign in to post a comment or reply.
Loading…