A fish out of water: Test SMTP using Command Prompt

  • Sandro Pereira
  • Nov 11, 2022
  • 3 min read

You may already know that I usually use the series A Fish Out of Water when I want to write something that goes a little bit off-topic on my main blog topic: Enterprise Integration. This time is not an Enterprise Integration topic, but is somehow related to it, since we are going to learn a possible way to troubleshoot SMTP issues that can be used as a channel in our integration solutions.

While working with BizTalk Server, I sometimes needed to send email notifications or messages. In some cases, we use Office 365 accounts to authenticate on the SMTP Server and send emails through that account, but in some cases, we may have an internal SMTP Server with anonymous authentication that doesn’t require any account to send emails or a valid email to specify on the from. Of course, normally that doesn’t mean it is an “open bar” where everyone can send emails to and from anywhere they want. You should find some limitations through other types of settings you can perform on the SMTP server or in the network layer, like:

  • Only specific machines can access and send emails through that SMTP Server.
  • You can only use a specific sender, or you can only send emails internally to the organization.
  • and so on.

📝 One-Minute Brief

A simple and effective walkthrough that shows how to test SMTP connectivity using only the Windows Command Prompt. By using Telnet to interact directly with an SMTP server, you can verify connectivity, check authentication rules, detect relay restrictions, and troubleshoot BizTalk or integration scenarios that rely on email channels. This guide helps you confirm whether the SMTP server is correctly configured before using it in solutions.

To try to see if everything is set up correctly before you use BizTalk Server, for example, or even through troubleshooting errors, you can try to send an email through the Command Prompt. To do that, you need to:

  • Open Command Prompt using Start > Command Prompt or via Run > cmd.
  • You then need to do a telnet to the mail server by typing telnet <domain> <port> (usually, it is 25) and then pressing Enter.
  • Once connected, we must initiate the mail-sending process by typing helo.
    • The server will reply with 250 and Hello if successful.
telnet
  • We now need to specify the sending mail address by typing mail from:<email address> and then pressing Enter.
    • The server will reply with 250 if it is a valid sender.
  • After that, we specify the recipients by typing RCPT TO:<email address> and then pressing Enter.
    • The server will reply with 250 if it is a valid receiver.
telnet

Most of the time, if errors exist, you will find them in this first part of the process.

Now, to actually send an email, you need to:

  • Type data and press ENTER to begin the email content.
  • We first need to set the email subject by typing Subject:<Your Subject>, then pressing Enter twice.
  • Now start typing the message content of your email.  
  • To finish and close the message, do the following sequence:
    • Press Enter.
    • Type . (Period Key).
    • and press Enter again.

You may then receive a server response saying, for example, that the mail was queued for delivery.

Telnet
  • Type Quit and press Enter to exit telnet. 

Now you just need to verify if your email was received.

Hope you find this helpful! If you liked the content or found it useful and would like to support me in writing more, consider buying (or helping to buy) a Star Wars Lego set for my son. 

Thanks for Buying me a coffe
Author: Sandro Pereira

Sandro Pereira lives in Portugal and works as a consultant at DevScope. In the past years, he has been working on implementing Integration scenarios both on-premises and cloud for various clients, each with different scenarios from a technical point of view, size, and criticality, using Microsoft Azure, Microsoft BizTalk Server and different technologies like AS2, EDI, RosettaNet, SAP, TIBCO etc. He is a regular blogger, international speaker, and technical reviewer of several BizTalk books all focused on Integration. He is also the author of the book “BizTalk Mapping Patterns & Best Practices”. He has been awarded MVP since 2011 for his contributions to the integration community.

Leave a Reply

Your email address will not be published. Required fields are marked *

The Ultimate Cloud
Management Platform for Azure

Supercharge your Azure Cost Saving

Learn More
Turbo360 Widget

Back to Top