Site icon Mail250 – An AI driven Email Delivery Solution

How SMTP works?

How SMTP works

In this blog, I am going to tell you what is SMTP, and how SMTP exactly works.

SMTP

SMTP stands for Simple Mail Transfer Protocol. In a layman terms it is like a small language which consists of only few words. This language is used by the sender of the email to send email to the receiver of the email. In the real world, both the sender and the receiver are actually an application or so called computer programs. In technical terms, sender is called SMTP client and the receiver is called as SMTP server. SMTP is a standard language (protocol) used by all the application on this planet to send emails. However, the same cannot be used for receiving emails. For receiving one need to use POP or IMAP.

Still it is called as a protocol and not a language. This is because, it is not a free flow language, it is basically a set of rules. It is like the same rules as we have in military. Both the sender and the receiver has follow these set of rules like sender has to greet first in a particular way and so forth.

Email

Email, like our traditional letter, is nothing but a document. In a computer system it is a file, which needs to be transferred from one computer to another.

Now, let us dive into how actually SMTP client chats with the SMTP server in order to send an email. Below is the actual interactions between SMTP client and a SMTP server, with their explanations (it is taken from an actual SMTP client (php script) sending mail to Mail250’s SMTP server).

Below is the actual interaction of SMTP client with the SMTP server

Server says:

220 smtp.mail250.com ESMTP Welcome to Mail250 Emailing Server

As soon as SMTP client connects to the SMTP server, the server shows its name (with a banner).

Client says:

EHLO mypc

After this client is required to say hello, it is spelled as letter “e” before h is because it means server is using ESMTP. ESMTP is an SMTP with extensions.

Server says:

250-smtp.mail250.com at your service
250-8BITMIME
250-ENHANCEDSTATUSCODES
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250 STARTTLS

Server replies with the list of extensions i.e. list of services it provides.

Client says:

AUTH LOGIN

Then client asks for logging in, in order to get authenticated to send email.

Server says:

334 VXNlcm5hbWU6

Server replies in base64 encoded format. If you decode it then in clear text it get converted to “Username:”

You can encode/decode a clear text into base64 format using the below links:
https://www.base64encode.org/
https://www.base64decode.org/

You can get more information about base64 encoding on the below mentioned links:
https://en.wikipedia.org/wiki/Base64
http://stackoverflow.com/questions/201479/what-is-base-64-encoding-used-for

Client says:

dGVzdHVzZXI=

Client needs to reply in base64 encoded text as well. On converting it to clear text, it get converted to “testuser“ (this is a testuser, made for our example)

Server says:

UGFzc3dvcmQ6

Then server asks for password in base64 encoded format. If you decode it then in clear text it get converted to “Password:”

Client says:

dGVzdHBhc3M=

Client provides the password in base64 encoded text. On converting to clear text it get converted to “testpass“.

Server says:

235 2.7.0 Authentication successful

Self explanatory 😉

Client says:

mail from:<test@example.com>

Client provides sender’s email

Server says:

250 2.1.0 Ok

Server accepts its.

Client says:

rcpt to:<to@example.com>

Client provides receiver’s email, to whom mail needs to be sent.

Server says:

250 2.1.0 Ok

Server again accepts its.

Client says:

data

Client then initiate the email by using data command, that is, now the client will actually provide the email details.
Server says:

354 End data with <CR><LF>.<CR><LF>

Server agreed to begin email, additionally, server said that mail body will be ended if it founds these 5 characters in series.

Client says:

From: from@mail250.com
To: to@mail250.com
Date: 28 Aug 2016 05:57:35 +0000
Subject: This is a test email subject

This is a test email body

.

Client submits the email.

Note, each line till Subject is called as headers of the email. The header part and the body part of the email is separated by a new line.

Additionally, the email ended as it was stated by the server, that is, using new line characters + dot + new line characters.

Server says:

250 2.0.0 Ok: queued as q422cl78

Server responds that it is queued, and provide a id given to the mail inside the queue. Thus, one can search by this id inside the server to debug, in case something went wrong.

Client says:

QUIT

Client closes the connection.

Server says:

221 2.0.0 Goodbye!

Again self explanatory 🙂

Now, the server has accepted the email. However, it doesn’t mean that mail has been delivered to the recipients. This is because, this is a SMTP relay server. Thus, it has queued it. It will deliver it as per its own availability, that is, after sending all the mails which have been queued before this email. Also, the time of delivery depends upon the availability of the recipient’s mail server and various other factors like reputation of the sending server ip, sender domain reputation. We can’t cover all those in this blog 😉

I guess this will give you a bit of detailed idea on how SMTP actually works and how email clients, as well as servers communicate in SMTP with each other in order to send an email.

Hope you like it 🙂 Mail250 | Bulk mail Marketing Service

Click Here Fro Next Blog Related To Bulk Email Marketing

Email Marketing Service. Send Unlimited Bulk Emails at $20. SignUp for free.
Note: There is a rating embedded within this post, please visit this post to rate it.

 

Exit mobile version