Friday 22 September 2017

How to troubleshoot SMTP authentication using command

                                   How to troubleshoot SMTP authentication using command

Many IT professional face problem of mail not being sent from application or tool configured for mail alert. The first suspect goes to particular application or tool but root cause may be different that need other approach to follow, hence I found it worthy to write a blog on how to know if SMTP is fine with credentials used for mailing.

Steps:

  1. Open Linux terminal or Command prompt and telnet to SMTP server on listening port, in most cases it is TCP/25
  2. Now SMTP Server will respond back with a message
  3. Now type command "EHLO NICO" and there will be output of having multiple lines of response
  4. Now type command "AUTH LOGIN" and there will response 334 with encoded value "VXNlcm5hbWU6" which means "User name" enter SMTP username here in Base64 encoded format which is configured in application for mailing.
  5. Once you supply username's encoded value and hit enter, there will be response 334 with encoded value "UGFzc3dvcmQ6" which means "Password" enter above user's password in  Base64 encoded format which is configured in application for mailing.
  6. Now there will be response of server which indicate authentication succeeded or failure and you need to take further action accordingly.

Example:
telnet yoursmtpserver 25

Connected to yoursmtpserver
Escape character is '^]'.
220 yoursmtpserver ESMTP - VA Code Section 18.2-152.3:1 forbids use of this system for unsolicited bulk electronic mail (Spam)
EHLO NICO
250-yoursmtpserver
250-SIZE 75000000
250-STARTTLS
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250 STARTTLS
AUTH LOGIN
334 VXNlcm5hbWU6
"encoded username"
334 UGFzc3dvcmQ6
"encoded password"
235 ... authentication succeeded 
or
535 5.7.8 Error: authentication failed: UGFzc3dvcmQ6


Note: To encode username and password you can use free utility or online site that encode/decode base64 values. I recommend to change the password after troubleshooting if online encoding tool is being used.

encoding website: http://www.utilities-online.info/base64/#.WcTw6MgjHIU