An SMTP conversation would typically look like this:
- Client initiates a TCP connection to the server.
- The MTA should talk first (client should wait!) and print a line with some basic
indicators, e.g.:
where 2xx code indicates 'OK'.
220 myhost.g3rt.nl ESMTP Postfix (Debian/GNU) - The MTA may already reject the client at this point (e.g. IP blocklisted in RBLs).
- Note that Postfix servers sending mail out are also SMTP clients.
- The MTA should talk first (client should wait!) and print a line with some basic
indicators, e.g.:
- Negotiate capabilities, e.g. upgrade connection security with StartTLS.
- say
HELO mysmtpserver.g3rt.nl(orEHLOinstead ofHELO)- The MTA may reject the connection already at this point (e.g. invalid HELO name).
- say
MAIL FROM:<userx@y.foo.org>to indicate the envelope sender (Return-Path).- The MTA may reject the sender address at this point (e.g. prohibit impersonation, sender address non-existence).
- say
RCPT TO:<userc@d.bar.org>for every recipient.- The MTA may reject the recipients (e.g. to deny relay access).
- say
DATAto proceed to sending headers. - say
HeaderName: header valuefor every header. - say empty newline to proceed to sending the body.
- Send the body as given a negotiated transfer encoding and policy, typically MIME-encoded with lines wrapped up to 72 characters.
- say
.on a line of its own to indicate the end of the message.
At any stage the MTA can reply to the client with a reply code, indicating extra information, a successful completion or an error.