Install Telnet client on Server 2012 via PowerShell

20160614150939Every time I try to open the Telnet client on a new server I get a response stating that telnet is not recognized as an internal or external command, operable program or batch file. Meaning it isn’t installed, because the Telnet client is not installed by default. Installing it via the GUI is a hassle so instead we can do it via PowerShell.

To install the Telnet client on Server 2012 via PowerShell perform the following steps:

1. Open Powershell.
2. Run the command install-windowsfeature “telnet-client” per the below:


And that’s it, no need to even reboot :)

The Telnet client is now ready and waiting for some command line action.

Testing SMTP Server from the command line

In a previous post I explained how to use the SMTPDIAG tool to test that SMTP and DNS were configured correctly. The tool does not however send a test message.

In this post I wil demonstrate two methods of sending test emails via the command line.

Method 1 – Telnet

I am going to assume that your server is Windows Server 2008 R2, although these steps will work on Server 2003 also. Another assumption is that you have the telnet client installed. If you don’t have it installed follow the steps in this post and then follow these instructions:

1. Fire up the command prompt and type telnet:


2. At the telnet prompt, type set LocalEcho then press ENTER:

Welcome to Microsoft Telnet Client
Escape Character is 'CTRL+]'
Microsoft Telnet>set LocalEcho

3. Then type open localhost 25 and then press ENTER.

Welcome to Microsoft Telnet Client
Escape Character is 'CTRL+]'
Microsoft Telnet>set LocalEcho
Local echo on
Microsoft Telnet>open localhost 25

The output will look similar to this:

220 Microsoft ESMTP MAIL Service, Version: 7.5.7601.17514 ready at Fri, 23 Aug 2013 01:02:03 +0000

4. Type helo me and then press ENTER. You should receive a 250 response from the SMTP Server meaning that it has accepted your command:

helo me
250 Hello []

5. Then type the mail – obviously fill in the email address you are actually sending from and then press ENTER. The output will be similar to the below:

250 2.1.0 OK

6. Type rcpt – the address you are sending to and then press ENTER. The output will be similar to the below:

250 2.1.5

7. Type Data and then press ENTER, resulting in the following:

354 Start mail input; end with <CRLF>.<CRLF>

8. Type Subject:This is a test email and then hit ENTER twice. Then type This is a test email being sent via telnet and hit ENTER. Hit ENTER again, then type a full stop (.), and then hit ENTER once more:

Subject:This is a test email

This is a test email being sent via telnet


9. The resulting output would be similar to this:

250 2.6.0 <> Queued mail for delivery

It means that an email has been generated and is in the queue and is ready to be delivered.

10. Now that you have finished, type quit and the connection to the SMTP Server will be closed:

221 2.0.0 Service closing transmission channel

Connection to host lost.

A screenshot of all the commands being run is below:


That’s it. Now go to your email account and verify that the email has arrived successfully. In my case I received the email below to my Gmail account:


Method 2 – PowerShell

The PowerShell method is much less tedious and is my recommended way of sending email via the command line on Windows. Assuming that PowerShell is installed on your server, launch the console and simply run the command below, ensuring that you complete the sending and receiving email addresses plus the subject and body text:

PS C:\Users\admin> Send-MailMessage -SMTPServer localhost -To -From -Subject "This is a test email" -Body "Hi Japinator, this is a test email sent via PowerShell"

The above command sent an email to my Gmail account, a screenshot of the email generated is below:


The PowerShell method is far easier to use. You can save the command in a .ps1 file and run it on demand whenever you need to test sending/routing of mail.

How To Test SMTP Services Manually in Windows Server 2003
PowerShell Send-MailMessage command line reference