Monday, May 21, 2012

Sending E-Mail As An Authenticated User Using Telnet

The first thing you have to do is generate your AUTH PLAIN token from the command line (assuming Linux):
perl -MMIME::Base64 -e 'print encode_base64("\000your-user\@your-domain.com\000your-password");' 
Now telnet to your mail server:
telnet mail.your-domain.com
Trying 1.2.3.4...
Connected to mail.your-domain.com.
Escape character is '^]'.
220 mail.your-domain.com ESMTP
Now we need to say Hi:
ehlo my-current-hostname.com
And we'll receive the list of supported commands:
220 mail.your-domain.com ESMTP
250-mail.your-domain.com
250-STARTTLS
250-PIPELINING
250-8BITMIME
250-SIZE 0
250 AUTH LOGIN PLAIN CRAM-MD5
We want to AUTH PLAIN using the token we created:
AUTH PLAIN [token here]
If your login credentials are accepted you'll receive:
235 ok, go ahead (#2.0.0)
Now you can send a message (I've included the numeric response codes below each command, you wouldn't enter those):
MAIL FROM: your-user@your-domain.com
250 ok
RCPT TO: another-user@another-domain.com
250 ok
DATA
354 go ahead
To: another-user@another-domain.com
From: your-user@your-domain.com
Subject: This Is How To Send An Authenticated Email Via Telnet 
Date: Mon, 21 May 2012 12:00:00 -0500
Testing auth plain via telnet.
To end the message well place a period on it's own line and then hit enter.
.
250 ok
QUIT
And there you have it!