HowTo: Send Email from an SMTP Server using the Command Line

The SMTP (Simple Mail Transfer Protocol) is an Internet standard for electronic mail (Email) transmission across Internet Protocol (IP) networks.

This tutorial shows how to connect to SMTP mail server and send an Email using the ‘telnet’ command.

Step 1: Open a connection from your computer to an SMTP mail server

$ telnet smtp.domain.ext 25
220 smtp.domain.ext ESMTP Sendmail ?version-number?; ?date+time+gmtoffset?
  • smtp.domain.ext – Your mail server;
  • 25 – Default port for SMTP.

Step 2: Declare your domain name or IP-address

You can set or anything you want in ‘HELO’, because the server doesn’t check its authenticity, that is one of the drawbacks of this protocol.

250 smtp.domain.ext Hello [], pleased to meet you

Step 3: Set sender’s email

> MAIL FROM: sender@adress.ext
250 2.1.0 sender@adress.ext... Sender ok

Step 4: Set recipient’s email

> RCPT TO: recipient@adress.ext
250 2.1.5 recipient@adress.ext... Recipient ok

Step 5: To write the message, type DATA and press ‘Enter’

354 Enter mail, end with "." on a line by itself

Step 6: On the first line type ‘SUBJECT: Your Subject’ and press ‘Enter’ twice

> SUBJECT: Test message

Step 7: Continue typing your message

this is a TEST message, 
please don't reply.
Thank you.

Step 8: Put a single period (.) on a line by itself and press ‘Enter’ to send your message.

> .
250 2.0.0 ???????? Message accepted for delivery

Step 9: Close the connection

221 2.0.0 closing connection
0 (0)
Article Rating (No Votes)
Rate this article
There are no attachments for this article.
There are no comments for this article. Be the first to post a comment.
Full Name
Email Address
Security Code Security Code
Related Articles RSS Feed
Automatic YUM Updates with Yum-cron
Viewed 547 times since Fri, Oct 26, 2018
Using Official Redhat DVD as repository
Viewed 845 times since Mon, Oct 29, 2018
18 Quick ‘lsof’ command examples for Linux Geeks
Viewed 2546 times since Sun, Jun 30, 2019
logrotate Log Rotate Configuration
Viewed 694 times since Sun, Jan 12, 2020
Enabling automatic updates in Centos 7 and RHEL 7
Viewed 641 times since Wed, Oct 17, 2018
How to sort IP addresses in Linux
Viewed 1328 times since Sun, May 20, 2018
linux ssh How to Hide the OpenSSH Version Details when Telnet to Port 22
Viewed 338 times since Wed, Apr 22, 2020
RHEL: iSCSI target/initiator configuration on RHEL6
Viewed 1201 times since Sat, Jun 2, 2018
RHEL: Remove existing SAN LUNs
Viewed 1055 times since Sat, Jun 2, 2018
Using grep to find string in files
Viewed 366 times since Fri, May 15, 2020