Telnet email with authentication

In the course of email server administration, we sometimes need to perform testing against the SMTP server using only the telnet command. Traditionally, this is done with just a few lines following a successful telnet. The traditional method looks something like the following:

telnet (your email server) 25 !! This connects you to the SMTP server
helo !!This tells the server you are ready to send some commands
MAIL FROM: (your email address) !! Must be valid on the sending server, this is your FROM address
RCPT To: (the recipient address) !!This tells the server who to send the message to
DATA !!Everything below this line goes into the body of the message
Press enter !!This is simply a line feed
(body of the message to send)
Press enter !!This is simply a line feed
. !!Indicates you are done. Just a simple period on a line by itself following a line feed
Press Enter !!This is simply a line feed. A line feed, then period, then another line feed tells the server you are done, send the message

The above work great if the server does not require authentication to relay a message. Unfortunately this is not the case 99% of the time. To telnet and send a message with authentication requires a couple changes:

ehlo !! Notice the difference here. HELO is the original command. EHLO is an enhanced command set that allows a few new commands
AUTH LOGIN This command is how you enter the username and password. You will not be prompted for either. Simply enter the data required. First the username, then the password. The username is DOMAIN\USERNAME, but must be entered in BASE64. You can find a free converter at http://ostermiller.org/calc/encode.html.
(BASE64 username)
(BASE64 password)

All the rest of the commands are the same!

Have Fun!

Ray

Drupal 6 Appliance - Powered by TurnKey Linux