cover-img

How to send emails using Telnet

20 June, 2023

0

0

0

Telnet or Teletype Network Protocol is a client/server application protocol. It allows users to connect with the email servers directly from the command line of their computer.

The primary purpose of Telnet is to establish a standardized connection between terminal-oriented devices and processes (RFC 854). However, it’s also widely used for sending emails and, in that process, testing the Simple Mail Transfer Protocol (SMTP) connection.

Today we’ll explain how to send emails using Telnet on Windows and Linux operating systems.

Send emails via Telnet on Windows

Prerequisites

  • Administrator access or equivalent
  • Configured SMTP server
  • Telnet enabled on the host’s computer or machine
  • Basic knowledge of PowerShell and command prompt commands

Installing the Telnet client

Most versions of Windows operating systems don’t have Telnet enabled by default. So, to get started, first, we need to install the Telnet client. The installation process will differ slightly depending on the Windows version you’re using. Generally, we have three main options:

  • Installing using the command line;
  • Installing using the PowerShell;
  • Installing from the Control Panel.

Installation using the command line

Press the Windows key or click the Start button. Locate the Start Search box, type cmd, and hit Enter. Right-click on the Command Prompt and press Run as administrator. That way, you’ll have the right to complete the installation. The next step is to dial in a specific command in the command line.

For Windows 7, Windows Server 2008 R2, Windows Server 2008, or Windows Vista, type in the following command and press Enter:

pkgmgr /iu:"TelnetClient"

For Windows 8 and above, type in this command and press Enter:

dism /online /Enable-Feature /FeatureName:TelnetClient

Wait for the installation to be completed. You should receive a confirmation message on newer versions of Windows OS.

Installation using PowerShell

Another option is to use PowerShell to install the Telnet client. However, it’s only applicable to Windows 8.1, Windows 10, Windows Server 2012 R2, or later.

Open the PowerShell administrator window, type the following command, and press Enter.

Enable-WindowsOptionalFeature -Online -FeatureName TelnetClient

Wait for the installation to be completed.

Installation using Control Panel

Finally, you can install the Telnet client from the Control Panel. To do so, find Programs (or Programs and Features) and open it. Locate Turn Windows features on or off and click on it. You’ll see a Windows Features box. Find Telnet Client and mark the checkbox. Then press OK. Wait for the installation to be completed and restart the computer to apply the changes.

For other installation options, refer to the Microsoft documentation.

Sending the emails

The email-sending process follows the logic and order of SMTP transmission: handshake, transmission, and termination of the session. It uses SMTP commands and connects to the server through a TCP port. Check out this blog post to find more information on SMTP operation.

Note: Telnet isn’t a secure way to send an email. It establishes an unencrypted connection, as it doesn’t support SSL or TLS. This means that anyone with access to your network can hijack the transmission and access the contents of your message.

You can’t connect to SMTP servers with authentication either, as most of them require TLS or SSL encryption before allowing LOGIN and PLAIN authentication methods (authentication without TLS is allowed only on test SMTP servers). You should use OpenSSL instead of Telnet to connect to SMTP servers with encryption. We’ll be talking about OpenSSL below.

To start an SMTP session, you’ll need the full domain name or the IP address of the SMTP server you’re trying to connect to. For example, if we were to use Mailtrap Email Testing, we’d enter sandbox.smtp.mailtrap.io.

You’ll also need to identify the port, which can be 25, 587, 465, or 2525. The port number depends on the configurations of the SMTP server you’re trying to connect to. Most SMTP servers block transmissions through port 25. Port 465 is suitable when sending emails with SSL encryption, while port 587 and 2525 should be used with TLS encryption.

Type the command:

telnet sandbox.smtp.mailtrap.io 25

Note: You won’t be able to use Mailtrap Email Testing for these purposes in real life as it doesn’t accept Telnet connections through port 25. The code sample above is for illustrative purposes only.

You’ll see the response starting with code 220 if the connection is successful. For example,

220 sandbox.smtp.mailtrap.io ESMTP server ready

The next step is to identify yourself to the SMTP host.

EHLO example.com or HELO example.com

Note: The HELO command will initiate an SMTP connection without service extensions. Therefore, corresponding ESMTP commands (such as STARTTLS, for example) won’t be supported.

All the supported SMTP extensions will be listed in the response. Each line will start with 250, indicating a successful connection.

250-sandbox.smtp.mailtrap.io
250-PIPELINING
250-SIZE 10485760
250-ETRN
250-STARTTLS
250-AUTH LOGIN PLAIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN

Then you can go ahead and transfer the necessary email fields according to the SMTP specification. First, type MAIL FROM, then RCPT TO, and then type DATA.

MAIL FROM: <sender@example.com>
250 2.1.0 Sender OK
RCPT TO: <recipient@example.com>
250 2.1.5 Recipient OK
DATA
354 Start mail input; end with <CRLF>.<CRLF>
From: sender@example.com
To: recipient@example.com
Subject: Telnet email

This is my first test message sent using the Telnet client on Windows
.
250 2.0.0 Ok: queued as ABC123456789

To end the session, you should type the QUIT command. The server will respond with 221 2.0.0 Service closing transmission channel, and the connection will be terminated.

A complete sample will look something like this:

telnet sandbox.smtp.mailtrap.io 25
220 sandbox.smtp.mailtrap.io ESMTP server ready
EHLO example.com
250-sandbox.smtp.mailtrap.io Hello
250-SIZE 37748736
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-X-ANONYMOUSTLS
250-AUTH NTLM
250-X-EXPS GSSAPI NTLM
250-8BITMIME
250-BINARYMIME
250-CHUNKING
250 XRDST
MAIL FROM: <sender@example.com>
250 2.1.0 Sender OK
RCPT TO: <recipient@example.com>
250 2.1.5 Recipient OK
DATA
354 Start mail input; end with <CRLF>.<CRLF>
From: sender@example.com
To: recipient@example.com
Subject: Telnet email

This is my first test message sent using the Telnet client on Windows
.
250 2.0.0 Ok: queued as ABC123456789
QUIT
221 2.0.0 Service closing transmission channel

Send emails using Telnet on Linux

Sending emails using Telnet on a Linux console is mostly similar to Windows. The difference is in the installation process only.

Prerequisites

  • Any version of the Linux distribution
  • Administrator access via root user or sudo command
  • Telnet
  • Working mail server

Installing the Telnet client

If the Telnet client isn’t installed on your machine, you can install it from your package manager. Specific commands will differ depending on the Linux distribution you’re using.

For Arch Linux and Manjaro, type in the following command in the terminal window and press Enter:

$ sudo pacman -S inetutils

For Ubuntu, Kali Linux, Debian, and Linux Mint:

$ sudo apt install telnet

For Red Hat, Fedora, and Centos:

$ sudo dnf install telnet

You’ll be prompted to enter your administrator password. Type it in and press Enter once again. Wait for the installation to be completed.

Sending the emails

To start sending emails, start the Telnet session by typing this command:

$ telnet sandbox.smtp.mailtrap.io 25

Then proceed the same way we described above. Don’t forget to follow the exact order of SMTP commands, otherwise, the transmission won’t be successful. If you misspell any of the commands, you won’t be able to make corrections with backspace. It’s recommended to press Enter, wait for the error message, and send a correct command afterward.

Continue reading about the steps in Mailtrap blog post.
https://mailtrap.io/blog/telnet-send-email/

0

0

0

More Articles

Showwcase is a professional tech network with over 0 users from over 150 countries. We assist tech professionals in showcasing their unique skills through dedicated profiles and connect them with top global companies for career opportunities.

© Copyright 2025. Showcase Creators Inc. All rights reserved.