In this guide, we’ll show the step by step instructions to send an email using Telnet on a Linux system. This a great way to test your mail server configuration such as exim, sendmail or postfix without the need for an email client.
In this tutorial you will learn:
- How to install Telnet on major Linux distros
- How to send an email using Telnet protocol on Linux
|Category||Requirements, Conventions or Software Version Used|
|System||Any Linux distro|
|Software||Telnet, mail server such as Sendmail|
|Other||Privileged access to your Linux system as root or via the
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
Other than an installed and configured mail server, you’ll also need the Telnet package installed on your system in order to use this guide. It may already be installed by default, but if not, use the appropriate command below to install it with your system’s package manager.
$ sudo apt install telnet
$ sudo dnf install telnet
$ sudo pacman -S inetutils
Send email using Telnet
Follow the step by step instructions below to send an email on Linux using Telnet.
- First, telnet to your mail server:
$ telnet mail.mymailserver.com 25
- Use the
HELOcommand to tell the mail server which domain you are coming from:
- Now we need to state from which address this email will be sent. This is done with the
MAIL FROM: email@example.com
- Next step is to specify recipient with
RCPT TO:. Use
RCPT TO:multiple times if you would like to send your email to multiple email addresses.
RCPT TO: firstname.lastname@example.org
- Now we can start writing some subject and body. To do that we need to use the
DATAcommand. First type
Subject:and the body. Once done, enter
.to send the email to be queued.
DATA Subject: Sending an email using telnet Hello, Here is my body? Do you like it? cheers .
- Do not forget “.” at the end of the message. To quit, type:
That’s all there is to it. You can now check your email to ensure that it has sent correctly. If not, it indicates that there is most likely something awry with your mail server configuration.