toucheatout 2006-03-26 22:03 IT
The protocol also is plain text and the process is quite simple. It is actually very simple to send an email. In the following example, we will send an email from fake@example.net to a@example.com
Find the MX responsible for the target recipient's domain example.com
dig mx example.com
The result is shown on the line(s) with MX. Prioritary MX is the one having the smallest value (from 0 - most prioritary - to 100 - least prioritary).
For the unfortunates under windozs and those not having the dig utility, use
nslookup
set type=mx
example.com
We'll suppose that the MX obtained is mail.example.com
Do the deed and write the email
Bear in mind that invalid commands are ignored, so you can retype them. You can cancel the whole thing altogether (cleanly) with RSET.
- Connect to the SMTP port (25) with telnet on the command-line
telnet mail.example.com 25
You should see a 220 greeting code.
- Say EHLO !
EHLO example.net (optionnaly, older style HELO example.net)
The server should answer with 250 code(s) and informations.
- Tell who's writing
MAIL FROM: fake@example.net
Answer is 250 OK or the reason of the failure.
- Tell who's the recipient
RCPT TO: a@example.com
Answer should be 250 OK if the email address is valid. This command can be inputted more than once to send to several recipients on the same domain.
- Write the actual email:
End of message end is expressed with a single dot ('.') on an otherwise blank line.
DATA
Following the 354 answer code, input the message (with some headers before if desired)
Subject: Dear A
To: a@example.com
I have been happy to hear that you are in the example company
.
If the To: is omitted, the message would seem to be issued to 'undisclosed recipients'. Any header after DATA is 100% optional.
The server should announce you that the message has successfully been queued (and give you the reference), with a 250 code.
- Quit
QUIT
And an ultimate 221 Ciao bye should precede the closure of the connexion.