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 gmail.com Non-authoritative answer: gmail.com mail exchanger = 30 alt3.gmail-smtp-in.l.google.com. gmail.com mail exchanger = 40 alt4.gmail-smtp-in.l.google.com. gmail.com mail exchanger = 5 gmail-smtp-in.l.google.com. gmail.com mail exchanger = 10 alt1.gmail-smtp-in.l.google.com. gmail.com mail exchanger = 20 alt2.gmail-smtp-in.l.google.com.
Select the low preference mail exchange server, and here I took gmail-smtp-in.l.google.com.
Sending email message through SMTP commands
[root@server ~]# telnet gmail-smtp-in.l.google.com 25 Trying 184.108.40.206... Connected to gmail-smtp-in.l.google.com. Escape character is '^]'. 220 mx.google.com ESMTP y15si15797390qci.149 helo 250 mx.google.com at your service mail from:email@example.com 250 2.1.0 OK y15si15797390qci.149 rcpt to:firstname.lastname@example.org 250 2.1.5 OK y15si15797390qci.149 data 354 Go ahead y15si15797390qci.149 to:karthikeyan .email@example.com from:firstname.lastname@example.org Subject: Email messaging Test message from my VPS server Regards, Karthik . 250 2.0.0 OK 1291139912 y15si15797390qci.149 quit 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 from:email@example.com. And the recipient address through rcpt to:firstname.lastname@example.org.
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.
Note: You can send email messages similar to any other email providers like Yahoo, Outlook with the same technique.