Testing SMTP AUTH through Telnet

There are plenty of instructions out there on how to connect to a SMTP server through telnet to test a mail server. What is not as widely documented is how to test to make sure that SMTP authentication is working. All of the SMTP commands are the same except for a couple exceptions. First, instead of issuing “helo hostname”, you need to type “ehlo hostname”. After that you need to login. Testing smtp authentication is not done in plain text like POP3 or IMAP. You need to encode your username and password together. To do this you can run a simple perl statement from the command line. It’s important to remember at this point that the command is in perl, so if there are any funky characters in the password you will need to escape them with a backslash. The username and password also need to be preceded with 00.

perl -MMIME::Base64 -e ‘print encode_base64(“00user@domain.com00pa$$word”)’

Output:

AHVzZXJAZG9tYWluLmNvbQBwYSQkd29yZA==

Then you simply type “AUTH PLAIN” and then paste the encoded output from the previous statement (all on one line):

AUTH PLAIN AHVzZXJAZG9tYWluLmNvbQBwYSQkd29yZA==

235 Authentication successful

If you get this, then either you did the encoding wrong or your mail server is setup wrong . . .

535 Error: authentication failed

Good Luck!

1 thought on “Testing SMTP AUTH through Telnet

Leave a Comment