Send an email using Telnet

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

Send an email using Telnet

Send an email using Telnet

Software Requirements and Linux Command Line Conventions
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.

  1. First, telnet to your mail server:
    $ telnet mail.mymailserver.com 25
    
  2. Use the HELO command to tell the mail server which domain you are coming from:
    HELO linuxconfig.org
    


  3. 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
    
  4. 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: someone@example.com
    
  5. Now we can start writing some subject and body. To do that we need to use the DATA command. First type DATA followed by 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
    .
    
  6. 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.



Comments and Discussions
Linux Forum