SMTP Commands to Send Email Message

(Last Updated On: September 26, 2016)

Sending an email message to a mail account using Telnet and SMTP commands. We are going to learn how to send an email message through SMTP commands. From one destination, without any client software.

I’ve tested it and sent an email message to my Gmail account from my test Virtual private server (VPS). Since the broadband, IP is blacklisted and not permitted for sending email messages. Follow the below-recommended steps and continue until the end of the post.

Finding out mail server

I recommend using the NSLOOKUP command for Linux and Windows Operating system.

#nslookup -q=mx
Non-authoritative answer:       mail exchanger = 30       mail exchanger = 40       mail exchanger = 5       mail exchanger = 10       mail exchanger = 20

Select the low preference mail exchange server, and here I took

Sending email message through SMTP commands

[root@server ~]# telnet 25
Connected to
Escape character is '^]'.
220 ESMTP y15si15797390qci.149
250 at your service
250 2.1.0 OK y15si15797390qci.149
250 2.1.5 OK y15si15797390qci.149
354  Go ahead y15si15797390qci.149
Subject: Email messaging

Test message from my VPS server

250 2.0.0 OK 1291139912 y15si15797390qci.149
Connection closed by foreign host.

We connected to the Google SMTP server on the port 25. With Telnet command, after a few seconds, the Google SMTP server welcomes us. Usually, SMTP communication starts with HELO command. Next, you need to provide mail And the recipient address through rcpt

After providing mail from and rcpt to, you need to start Data. Where you need to provide To, From and Subject details and end the data by keeping (.) dot at the last of the conversation. After completing the data part, your email message queued up to recipient address.

To exit this session type quit and exit the SMTP session, after that you can check your Gmail account.

SMTP Commands Email message


Note: You can send email messages similar to any other email providers like Yahoo, Outlook with the same technique.