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 try or troubleshoot SMTP issues that can be used as a channel on our integration solutions.
While working with BizTalk Server, sometimes I had the need to send email notifications or send messages thru email. In some cases, we use Office365 accounts to authenticate on the SMTP Server and send emails thru 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 that it is an “open bar” where everyone can send emails from and to anywhere they want. You should find some limitations thru other types of setting you can perform on the SMTP server or in the network layer like:
- Only specific machines can access and send emails thru that SMTP Server.
- You can only use a specific sender, or you can only send emails internally to the organization.
- and so on.
To try to see if everything is set up correctly before you use BizTalk Server, for example, or even thru troubleshooting errors, you can try to send an email thru 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.
- 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.
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 subject of the email by typing Subject:<Your Subject> and 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.
- Type Quit and press Enter to exit telnet.
Now you just need to verify if your email was received.