Jun 12, 2016

f Comment

A Complete Example Of Using Telnet to Connect to an SMTP Server to Send out an Email!

Amazon Let's say you signed up for an SMTP server so that you can use it to send emails. How do you go about testing your SMTP server? Your SMTP server service provider may claim that your SMTP server is ready, but how do you verify that your SMTP server is ready to send out emails? This post will walk you through it step-by-step.

Install telnet

If you use Unix, chances are you already have telnet installed. If you use Windows you should have telnet already installed but you may need to activate it. Google "telnet for windows" for help if you are having trouble.

Base64 encode your user name and password

Basically you need these things from your SMTP service provider: SMTP host URL and SMTP login credentials (user name and password). Your SMTP service provider may offer different ports, e.g. port 465 with SSL encryption or port 25 without SSL encryption. Let's assume the following for the purpose of this tutorial:

port: 25.
SMTP host URL: my-smtp-host-url.com
SMTP user name: user
SMTP password: anEasyPassword

The first thing you need to do is base64 encode your user name and password. Go to Online Base64 Encoder to base64 encode your user name and password, as follows:

user => dXNlcg==
anEasyPassword => YW5FYXN5UGFzc3dvcmQ=

Make sure you don't introduce spaces or line breaks in the text field of the base64 encoding tool.

You'll need to enter these values with the SMTP command called auth login below.

Open a Unix terminal

Let's run some commands to use telnet to connect to an SMTP server to send out an email!

The following is a trace of running Unix commands to verify that your SMTP server is working. It should be pretty self-explanatory.

$ telnet my-smtp-host-url.com 25
Trying 1.2.3.4...
Connected to my-smtp-host-url.com.
Escape character is '^]'.
220 mta.my-smtp-host-url.com ESMTP service ready
auth login
334 VXNlcm5hbWU6
dXNlcg==
334 UGFzc3dvcmQ6
YW5FYXN5UGFzc3dvcmQ=
235 authentication succeeded
mail from:any@email.com
250 MAIL ok
rcpt to:my@email.com
250 ok
data
354 send message
from: any@email.com
to: my@email.com
subject: subject line
body line 1
body line 2
let's end body with a single period next
.
250 message received
quit
221 mta.my-smtp-host-url.com says goodbye
Connection closed by foreign host.
$

If you don't see "235 authentication succeeded", it means the authentication failed. You should contact your SMTP server service provider.

If you see "250" at the end, it means that the requested mail action has been completed, meaning the email should have been sent successfully. There is a chance that something is wrong and the email doesn't get to the destination. If you don't get the email, check your spam folder.

Questions? Let me know!
Please leave a comment here!
One Minute Information - by Michael Wen
ADVERTISING WITH US - Direct your advertising requests to Michael