What is the best place to keep telnet commands used to test a SMTP service than you personal blog? 
Communication between clients and SMTP services happens using simple text commands and after each commend sent by the client, the SMTP server replies with a response code followed by a message.
You can use these commands to test if your SMTP is running correcly and compare them with my SMTP's conversation to see what the server should reply.
As you will see my SMTP service is installed into a windows enviroment using IIS 6.0 and with the NTLM authentication enabled.
Let's see first few besic commands:
| Command |
Example |
Description |
| HELO (now EHLO) |
EHLO 193.56.47.125 |
Identification using the IP address or domain name of the originator computer |
| MAIL FROM: |
MAIL FROM: originator@domain.com |
Identification of the originator's address |
| RCPT TO: |
RCPT TO: recipient@domain.com |
Identification of the recipient's address |
| DATA |
DATA message |
Email body |
| QUIT |
QUIT |
Exit the SMTP server |
| HELP |
HELP |
List of SMTP commands supported by the server |
AUTH LOGIN
|
AUTH LOGIN |
Authenticates you user |
And now, see how can you use these commands with a SMTP server.
telnet mail.server.com 25
Trying 70.87.xxx.xxx...
Connected to mail.server.com.
Escape character is '^]'.
220 C34495-51701 Microsoft ESMTP MAIL Service, Version: 6.0.3790.3959 ready at Fri, 25 Sep 2009 14:27:48 +0200
ehlo myrocode.com
250-C34495-51701 Hello [93.62.0.xxx]
250-AUTH GSSAPI NTLM LOGIN
250-AUTH=LOGIN
250-TURN
250-SIZE
250-ETRN
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-8bitmime
250-BINARYMIME
250-CHUNKING
250-VRFY
250 OK
auth login
334 VXNlcm57uWU6
aXBlcmJvcmVh
334 UFFzc3dzcmQ7
aXBlcmIwMSE=
235 2.7.0 Authentication successful
mail from:miro@miro.com
250 2.1.0 miro@miro.com....Sender OK
rcpt to:test@myrocode.com
250 2.1.5 test@myrocode.com
data
354 Start mail input; end with <CRLF>.<CRLF>
ciaooooo
.
250 2.6.0 <C34495-51701DcBi4FS00000001@C34495-51701> Queued mail for delivery
quit
Connection closed by foreign host.
An important part of this communication is when it come's to autenticate your user: after AUTH LOGIN is send, you should provide first the username and then the password, both encoded using the base64 algoritam.
you can encode a string into a base64 format follwing this link