TODO
TODO
SMTP is the Simple Mail Transport Protocol. It:
nc
>.
This picture was stolen from RFC 2821:
The server could be the ultimate destination for the mail, or be a relay, or be a gateway. What it is is irrelevant to describing the protocol.
Each command gets a reply. The dialogue is “lock-step, one at a time.”
Commands and replies are encoded in US-ASCII. They are not case-sensitive.
“No sending SMTP system is permitted to send envelope commands in any character set other than US-ASCII; receiving systems SHOULD reject such commands, normally using '500 syntax error - invalid character' replies.” But there is a service extension called 8BITMIME.
This is a summary of the basic commands. It does not show all the options. See RFC 2821 for complete details.
HELO SP sendingdomain CRLF
EHLO SP sendingdomain CRLF
Sends the FQDN of the SMTP client, and the server responds to EHLO with the extensions that it supports.
MAIL SP FROM: reversepath CRLF
Identifies the sender mailbox
RCPT SP TO: forwardpath CRLF
Identifies the recipients
DATA CRLF
The server does not reply immediately
after seeing this line.
Instead the client follows this command with the message itself,
which terminates with the five-octet sequence
CR
LF
.
CR
LF
RSET CRLF
Aborts the current transaction but does not close the connection.
VRFY SP string CRLF
Asks server to confirm whether the arguement identifies a valid mailbox.
EXPN SP string CRLF
Asks server to confirm whether the arguement identifies a mailing list, and if so, to return the membership of the list.
HELP [SP string] CRLF
NOOP CRLF
QUIT CRLF
Server must send an OK reply to this then close the connection.
Every command must generate exactly one reply.
A reply is three digits followed by text. Some commands require the text and some do not. Usually the text is informative only.
Response can be single line
code SP text CRLF
or multiline
code - text CRLF code - text CRLF code - text CRLF code SP text CRLF
These are all the codes specified in RFC 2821:
211 | System status, or system help reply |
214 | Help message (Information on how to use the receiver or the meaning of a particular non-standard command; this reply is useful only to the human user) |
220 | <domain> Service ready |
221 | <domain> Service closing transmission channel |
250 | Requested mail action okay, completed |
251 | User not local; will forward to <forward-path> |
252 | Cannot VRFY user, but will accept message and attempt delivery |
354 | Start mail input; end with <CRLF>.<CRLF> |
421 | <domain> Service not available, closing transmission channel (This may be a reply to any command if the service knows it must shut down) |
450 | Requested mail action not taken: mailbox unavailable (e.g., mailbox busy) |
451 | Requested action aborted: local error in processing |
452 | Requested action not taken: insufficient system storage |
500 | Syntax error, command unrecognized (This may include errors such as command line too long) |
501 | Syntax error in parameters or arguments |
502 | Command not implemented |
503 | Bad sequence of commands |
504 | Command parameter not implemented |
550 | Requested action not taken: mailbox unavailable (e.g., mailbox not found, no access, or command rejected for policy reasons) |
551 | User not local; please try <forward-path> |
552 | Requested mail action aborted: exceeded storage allocation |
553 | Requested action not taken: mailbox name not allowed (e.g., mailbox syntax incorrect) |
554 | Transaction failed (Or, in the case of a connection-opening response, "No SMTP service here") |
The numbering scheme: first digit is kind of response (good, bad, incomplete), second is kind of error.
1yz - positive preliminary reply (send whether to continue or abort) 2yz - positive completion reply (you succeeded, start a new command if you want) 3yz - positive intermediate reply (ok so far, send more info) 4yz - transient negative completion reply (try again) 5yz - permanent negative completeion reply (command failed) x0z - syntax error x1z - this is a reply to your request for information x2z - reply related to connection x5z - receiver status information
Here is a simple session in which all the commands except
RSET are used, a headerless message is sent, and a bad command
is thrown in for fun. Oh yeah, and note you can pretend to be
someone else by specifying that person's address in the
MAIL FROM:
command.
220-hawk.mail.pas.earthlink.net ESMTP Exim 3.33 #1 Sat, 08 Mar 2003 23:22:30 -0800 220-NO UCE. EarthLink does not authorize the use of its computers or network 220 equipment to deliver, accept, transmit, or distribute unsolicited e-mail. EHLO lmu.edu 250-hawk.mail.pas.earthlink.net Hello 24-205-48-85.gln-eres.charterpipeline.net [24.205.48.85] 250-SIZE 10485760 250-PIPELINING 250 HELP MAIL FROM:pdorin@lmu.edu 250 <pdorin@lmu.edu> is syntactically correct RCPT TO:rtoal@lmu.edu 250 <rtoal@lmu.edu> is syntactically correct HELP 214-Commands supported: 214- HELO EHLO MAIL RCPT DATA AUTH 214 NOOP QUIT RSET HELP DATA 354 Please start mail input. hello how are you . 250 Mail queued for delivery. NOOP 250 OK VRFY president 252 VRFY not available EXPN everybody 550 EXPN not available to 24-205-48-85.gln-eres.charterpipeline.net (lmu.edu) [24.205.48.85] SQUIT 500 Unrecognized command QUIT 221 Closing connection. Good bye.
Here's another session. There's a header this time.
220-avocet.mail.pas.earthlink.net ESMTP Exim 3.33 #1 Sat, 08 Mar 2003 23:42:41 -0800 220-NO UCE. EarthLink does not authorize the use of its computers or network 220 equipment to deliver, accept, transmit, or distribute unsolicited e-mail. EHLO lmu.edu 250-avocet.mail.pas.earthlink.net Hello 24-205-48-85.gln-eres.charterpipeline.net [24.205.48.85] 250-SIZE 10485760 250-PIPELINING 250 HELP MAIL FROM:rtoal@lmu.edu 250 <rtoal@lmu.edu> is syntactically correct RCPT TO:rtoal@lmu.edu 250 <rtoal@lmu.edu> is syntactically correct DATA 354 Please start mail input. To: Whomever From: <pdorin@lmu.edu> Cc: Nobody Subject: MAKE $$$$ FAST!!!!!!! THIS IS NOT SPAM Ha ha ha - this message has a virus. La la la la. ROTFL. LOL LOL. SEND THIS MESSAGE TO EVERYONE YOU KNOW. . 250 Mail queued for delivery. QUIT 221 Closing connection. Good bye.
Post Office Protocol
RFC 1939
"Intended to permit a workstation to dynamically access a maildrop on a server host in a useful fashion."
So simple you can go get your mail yourself by writing a small script or just using Telnet. Used basically for downloading messages from the server and deleting them; IMAP offers much more.
POP3 servers generally listen on port 110. It is a command-and-reply protocol.
USER name
PASS string
QUIT
STAT
LIST [messageNumber]
RETR messageNumber
DELE messageNumber
NOOP
RSET
APOP
TOP messageNumber n
UIDL [messageNumber]
All replies have one of two formats:
+OK text
-ERR text
We’ve covered: