Telnet could be very useful when testing SMTP servers for email delivery. Let’s explore the steps required in order to send emails successfully.
Prerequisites
- Telnet
Solution
Step 1. Open Terminal and run the following command:
telnet smtp.gmail.com 25
Expected output:
Trying ...
Connected to smtp.somedomain.com.
Escape character is '^]'.
220 smtp.somedomain.com
Step 2. Send the EHLO command as a SMTP session initialization followed by the domain name or the IP address of the SMTP client.
EHLO devcoops.com
Expected output:
250-smtp.somedomain.com at your service
250-SIZE 35882577
250-8BITMIME
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8
Step 3. Use the MAIL FROM
command to specify the email sender.
MAIL FROM: <[email protected]>
250 2.1.0 MAIL ok
Step 4. Use the RCPT TO
command to specify the email destination address.
RCPT TO: <[email protected]>
250 2.1.5 <[email protected]> ok
Step 5. Now, before sending the message contents, run the DATA
command.
DATA
Step 6. Finally, send an email subject and a body. For instance:
Subject: Telnet test message
Hello there,
This is a test message send from Telnet!
Best,
DevCoops
Step 7. When you are done with the message, enter a new line, type .
and press Enter.
.
250 2.0.0 OK
Step 8. Last but not least, terminate the connection.
QUIT
221 2.0.0 closing connection
Conclusion
Keep in mind that sending emails through port 25 is an insecure practice and should be only used for testing purposes. A lot of email spam is relayed through port 25 since it’s primarily purpose is, as expected, SMTP relaying. Most of the cloud providers have this port blocked.
Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.