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 local.domain.name or anything you want in ‘HELO’, because the server doesn’t check its authenticity, that is one of the drawbacks of this protocol.

> HELO local.domain.name
250 smtp.domain.ext Hello local.domain.name [xxx.xxx.xxx.xxx], 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’

> DATA
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

Hello,
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

> QUIT
221 2.0.0 server.com closing connection
0 (0)
Article Rating (No Votes)
Rate this article
Attachments
There are no attachments for this article.
Comments
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
How to Synchronize Directories Using Lsyncd in Linux
Viewed 9941 times since Wed, Oct 31, 2018
RHEL: How to rebuild and/or patch a RPM package
Viewed 5565 times since Sat, Jun 2, 2018
RHEL: Building a custom kernel on RHEL 6
Viewed 1523 times since Sat, Jun 2, 2018
Turbocharge PuTTY with 12 Powerful Add-Ons – Software for Geeks #3
Viewed 10967 times since Sun, Sep 30, 2018
ubuntu How to reset lost root password on Ubuntu 16.04 Xenial Xerus Linux
Viewed 6736 times since Tue, Dec 8, 2020
Fałszujemy rozpoznania skanerów #1
Viewed 1759 times since Mon, May 21, 2018
How To: Create Self-Signed Certificate – OpenSSL
Viewed 1369 times since Mon, Feb 18, 2019
Logowanie za pomocą kluczy Secure Shell
Viewed 1711 times since Thu, May 24, 2018
RHEL: How to change a USER/GROUP UID/GID and all owned files
Viewed 12529 times since Sat, Jun 2, 2018
RHCS: Configure an active/backup pacemaker cluster
Viewed 6041 times since Sun, Jun 3, 2018