The SMTP (Simple Mail Transfer Protocol) is another protocol that you will almost certainly encounter as a web developer. After your web application has been developed, you will need to communicate with your customers through email. Email management and setup can be quite complex, especially when your email list exceeds thousands of subscribers. There are many options available when configuring email clients and servers. It is important to thoroughly understand the email exchange process before diving into this complex and intricate area of development.
SMTP is the standard protocol for electronic mail (email) transmission. Let's explore the chain of events that occur when you send an email from your favorite email service provider to your intended recipient.
It's important to note that there are two types of email exchange scenarios. First, the sender and receiver are exchanging emails originating from the same domain. So for example Jane@gmail.com is sending an email to firstname.lastname@example.org. This is known as local mail delivery.
In the second scenario, the sender's domain is different than the recipient. For example, email@example.com is sending an email to firstname.lastname@example.org. In this case, the email is transmitted externally, or outside of the local network.
Depending on the type of email exchange, the path to delivery will be quite different.
We will start with local mail delivery:
In this case, the sender sends the email from his/her workstation either through a web based mail service or from a locally installed email client such as outlook. Either way, the email is sent to the outgoing SMTP server that resides on the email provider's server - in this case (Gmail).
The SMTP server has a variety of tasks. It checks the data packets for header information. As you might recall, the header information in a packet contains the sender and recipient of the packet. The SMTP server would determine this email is intended for local mail delivery, because the originating email domain (email@example.com) is the same as the recipient (firstname.lastname@example.org).
This is done by separating the first part of the email from the email extension and comparing the results. The SMTP Server would determine that they are both Gmail.com accounts. In this case, Gmail's outgoing SMTP server would hold the emails internally in the email storage. This is until Joe connects to the server and downloads the mail waiting for him. The emails are downloaded using the POP3 protocol.
This Protocol is responsible for transmitting stored email messages to the designated recipient. The POP3 Server typically requires authentication such as a username and password, to connect and download the email messages in storage. If Joe is using an email client and downloads the messages from the POP3 server, the messages are transferred to Joe's Computer and deleted from the server. The POP3 server is not ideal for recipients who may use multiple computers to download their email messages.
Some businesses opt to use an IMAP server to handle email storage instead of POP3. With IMAP, email messages stay on the server even after they are downloaded by the recipients email client.