In this blog, I am going to tell you what is SMTP, and how SMTP exactly works.
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, 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
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).
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.
250-smtp.mail250.com at your service
250-AUTH PLAIN LOGIN
Server replies with the list of extensions i.e. list of services it provides.
Then client asks for logging in, in order to get authenticated to send email.
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:
You can get more information about base64 encoding on the below mentioned links:
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)
Then server asks for password in base64 encoded format. If you decode it then in clear text it get converted to “Password:”
Client provides the password in base64 encoded text. On converting to clear text it get converted to “testpass“.
235 2.7.0 Authentication successful
Self explanatory 😉
Client provides sender’s email
250 2.1.0 Ok
Server accepts its.
Client provides receiver’s email, to whom mail needs to be sent.
250 2.1.0 Ok
Server again accepts its.
Client then initiate the email by using data command, that is, now the client will actually provide the email details.
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.
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.
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 closes the connection.
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