Sometimes you need to test SMTP Authentication is working on your server, and you want to see what is going on in order to diagnose the problem.
In this case, you can verify SMTP authentication is working by using telnet and accessing the SMTP server directly. Below is a quick tutorial on how to test your server’s SMTP authentication
- Create or verify an existing username and password on the system
- Build the Base64 username/password
SMTP AUTH LOGIN will encapsulate the username and password as a Base64 string. This is used to prevent sending the username/password plaintext via the network connection. Using Perl, you can issue the following command to encode the username and password as a base64 string, which can be sent to the SMTP server. Note the @ symbol is escaped to pass the string via Perl.
# perl -MMIME::Base64 -e 'print encode_base64("myusername\@example.com")'
# perl -MMIME::Base64 -e 'print encode_base64("mypassword")'
- Access the local system. Commands we issue are highlighted in bold.
# telnet localhost 25
Connected to localhost (127.0.0.1).
Escape character is ‘^]’.
220 mydomain.com Welcome to the @Mail SMTP Server ( Exim )
250-mydomain.com localhost [127.0.0.1]
The above command will verfiy AUTH LOGIN is enabled on the server (250-AUTH LOGIN). If you do not see that then SMTP AUTH will fail the test which follows.
Send the following command to start the SMTP Authentication process
334 VXNlcm5hbWU6 ( Server returns username as a base64 string )
334 UGFzc3dvcmQ6 ( Server returns password as a base64 string )
235 Authentication succeeded
Congratulations, SMTP authentication is now enabled and confirmed working on your server. Note you must send the Base64 string of the username and password as two commands.