Use Telnet to Test SMTP

Okay, sometimes I forget the exact syntax and need to look this up from time to time.  Hope this can help me search it quicker in the future. 🙂

Firstly, make sure you have telnet enabled or installed. Or you have a tool that is able to telnet.  Next, make sure you have the relevant information needed to test the connector.  I will list the main ones here:

  • Network connectivity to the host.
  • <$hostname>: this can be internal name, FQDN, IP address, etc. of the SMTP host/server
  • <$SenderEmail>: Email address you will be sending from
  • <$RecipientEmail>: Email address you will be sending to
  • <$Subject>: Test subject or anything you want (i think this is optional)
  • <$Body>: This will be the body of the email
*Okay, one annoying thing about doing it this way is that you cannot use the backspace. If you use the backspace and it gives an error after you return, just type the command again without making a mistake.
  1. Open a command prompt (windows key+r, then type “cmd” and enter)
  2. type “telnet” then enter
  3. Type “set logfile <filename>” and press enter if you want a log of this session.
    1. This is optional but a good thing to do. It can be an existing directory and file name as well, or it will just go to the current directory.
  4. Type “OPEN <$hostname> 25” and press enter
    1. the “25” represents the port that the SMTP service is running on. 25 is the default, but can be 587 or whatever it’s configured as.
  5. Type “EHLO <$hostname>” and enter
  6. Type “MAIL FROM:<$SenderEmail>” and press enter
  7. Type “RCPT TO:<$RecipientEmail> NOTIFY=success,failure” and press enter
  8. Type “DATA” and press enter
  9. Type “Subject:<$Subject>” and press enter
  10. Press enter again
  11. Type “<$Body>” and enter
  12. Type a period (.), then press enter
    1. The period tells the server that you are done with the body and goes back into command mode
  13. Type “Quit” and enter to disconnect from the SMTP server
  14. Type “Quit” then enter to end your telnet session
    1. Alternatively, you can compose more tests, but to end your session, you need to type quit to exit Telnet.