Email is sent from a Mail User Agent (MUA) via Mail Delivery Agents (MDA), also known as servers or mail daemons.
The most common of these is sendmail, one of the first MDAs.
The mail protocol used between MUAs and MDAs and between MDAs is SMTP. This is a text based protocol, exhibiting the common characteristic of commands and arguments.
At the top level it is possible that a single email message is sent through multiple SMTP servers or gateways. In this case the view is store-and-forward.
The commands in the SMTP application protocol
are:
| Command | Description |
|---|---|
| HELP <command> | Show help about <command>, or what the commands are if you don't indicate one. |
| HELO <your domainname> | Introduce yourself. |
| VRFY <name> | Check if <namn> exists. If instead of a name you give a complete address, you may only get the address back, since this machine knows things only about its own users. |
| EXPN <name> | Like VRFY, but also show how letters to this address are handled, for example if they are forwarded. |
| VERB | Say that you will know as much (verbose mode) as possible about what the SMTP-server does. |
| QUIT | End your session. |
| RSET | Reset your session. The SMTP-server forgets everything you've said previously about the receiver and sender. |
| MAIL FROM: <your address> | Say who is sending the letter. |
| RCPT TO: <receiver> | Say who is receiving the letter. |
| DATA | The text that follows on the lines after this command are the letter itself, ending with a row that only contains a period, ".". |
| Code | Description |
|---|---|
| 050 | A debug message, i.e. a message that says something about how the server functioned internally. (The standard doesn't define this message code; it is an illegal answer, but one that is ignored by an SMTP-client). |
| 214 | Help message to the user. (Usually a reply to the command HELP.) |
| 220 | Ready to receive commands. (The start-up message you normally see when first connecting.) |
| 221 | Ends the session and closes the connection. (The normal answer to a QUIT command). |
| 250 | OK - the operation succeeded. |
| 354 | Enter in the text for the letter. |
| Error codes from SMTP | |
| 500 | Syntax error - the command you entered doesn't exist. |
| 501 | Syntax error - ther parameters to the command are wrong. |
| 503 | Bad sequence of commands
SMTP is picky when it comes to the order of commands! |
| 550
551 552 553 554 |
An error arose upon delivery of the letter.
Usually means that the receiver doesn't exist, or can't receive letters. |
To send a letter you must specify the following, and in this order:
POP has the following commands. Not all POP clients let you use them.
| command | function |
| USER username | Identify the user |
| PASS password | Authenticate the user |
| STAT | Return the number of unread messages and the size of the spool |
| RETR n | Retrieve message n |
| DELE n | Delete message n from the spool |
| LAST | Return the number of the last message returned via RETR |
| LIST [n] | Return the size of message n, or a list of all messages |
| RSET | Undelete all messages deleted |
| TOP n lines | Return the headers and lines lines of message n |
| QUIT | End the session |
The response from the POP server is either
+OK <text>or
-ERR <text>
All parts of the header and body are to be in ASCII text. This means that interesting data types are encoded. For example, a GIF image must be encoded in some fashion so that it can be represented as ASCII text. MIME has a "base64" type encoding for binary data.
MIME is used to describe the encoding and type of data included in a mail message. Each MIME element of an email message has
There are hundreds of MIME types for everything from audio, video, image, to various application formats. These are described as "type/subtype", for example:
text/plain application/msword image/jpeg