Test SMTP AUTH using Telnet





It is needed to get a base64 encoding of your username and password to test SMTP AUTH. You can use the following perl command to do it.

arun@localhost [~]# perl -MMIME::Base64 -e 'print encode_base64("username");'

Eg: perl -MMIME::Base64 -e 'print encode_base64("arun\@sudosu.in");'

arun@localhost [~]# perl -MMIME::Base64 -e 'print encode_base64("password");'

Or

you can use single base64 code by using the following format.

# perl -MMIME::Base64 -e 'print encode_base64("username\0username\0password");'
dGVzdEBzdW5ueXZpc2lvbgB0ZXN0QHN1

In that case you have to use AUTH PLAIN command in telnet session instead of AUTH LOGIN as follows.

AUTH PLAIN dGVzdEBzdW5ueXZpc2lvbgB0ZXN0QHN1


The above commmands will return a base64 encoding of the username and password. You have to keep this code and use it while using telnet.

connect to the mail server using Telnet:

telnet mailserver.com 25

Then Greet the mail server:

EHLO mailserver.com

Tell the server you want to authenticate with it:

AUTH LOGIN

The server should have returned 334 VXNlcm5hbWU6; this is a base64 encoded string asking you for your username, paste the base64 encoded username you created earlier, example:

HPxcqYBx7TpirE4

Now the server should have returned 334 UGFzc3dvcmQ6;. Again this is a base64 encoded string now asking for your password, paste the base64 encoded password you created, example:

LOMjmzLk3fjrvZP

Now you should have received a message telling you that you successfully authenticated. Once the authntication is successful, you can send mail using the smtp server.


Here i am giving you a test telnet session.

arun@localhost [~]# telnet mailserver.com 25
Trying 1.1.1.1...
Connected to mailserver.com (1.1.1.1).
Escape character is '^]'.
220-server1.exampledomain.com ESMTP Exim 4.66 #1 Wed, 09 May 2007 23:55:12 +0200
220-We do not authorize the use of this system to transport unsolicited,
220 and/or bulk e-mail.
EHLO mailserver.com
250-server1.mailserver.com Hello  [1.1.1.2]
250-SIZE 52428800
250-PIPELINING
250-AUTH PLAIN LOGIN
250-STARTTLS
250 HELP
AUTH LOGIN
334 VXNlcm5hbWU6
dXNlcm5hbWUuY29t
334 UGFzc3dvcmQ6
bXlwYXNzd29yZA==

235 Authentication succeeded

MAIL FROM: test@test.com
250 ok
RCPT TO: test@otherdomain.com
250 ok
DATA

Subject: My Telnet Test Email

Hello,

This is an email sent by using the telnet command.

Your friend,
Me

.




This entry was posted by Unknown. Bookmark the permalink.

Leave a Reply