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 sudo command. |
Conventions |
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command$ – requires given linux commands to be executed as a regular non-privileged user |
Install Telnet
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.
To install Telnet on Ubuntu, Debian, and Linux Mint:
$ sudo apt install telnet
To install Telnet on CentOS, Fedora, AlmaLinux, and Red Hat:
$ sudo dnf install telnet
To install Telnet on Arch Linux and Manjaro:
$ 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
HELO
command to tell the mail server which domain you are coming from:HELO linuxconfig.org
- Now we need to state from which address this email will be sent. This is done with the
MAIL FROM:
command:MAIL FROM: someaddress@linuxconfig.org
- Next step is to specify recipient with
RCPT TO:
. UseRCPT TO:
multiple times if you would like to send your email to multiple email addresses.RCPT TO: someone@example.com
- Now we can start writing some subject and body. To do that we need to use the
DATA
command. First typeDATA
followed bySubject:
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:
quit
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.