What is SMTP (Simple Mail Transfer Protocol)?
SMTP (Simple Mail Transfer Protocol) is a TCP/IP protocol used in sending and receiving emails over a network such as the internet. It is not an email retrieval protocol; however, it provides a standardized method for email delivery, thus enabling email clients and mail servers to exchange data. This facilitates widespread, easy and reliable email communication. Most email clients use SMTP, including Gmail, Microsoft Outlook, Apple Mail and Yahoo Mail.
SMTP client-server model
SMTP uses a client-server model. The client refers to the computer or web application that the user interacts with to write, send and access email messages. Users do not interact directly with mail servers, which are specialized computers whose functions are to send, receive and forward email.
In the SMTP client-server model, the following takes place:
- An email server uses SMTP to send a message from an email client to another email server.
- The server uses SMTP as a relay service to send the email to the receiving server.
- The receiving server uses an email client to download incoming mail via Internet Message Access Protocol (IMAP), for example, and places it in the recipient’s inbox. The recipient can then access and view the messages on demand.
How SMTP works
When a user clicks the send button in their email client, a Transmission Control Protocol (TCP) connection is established that links to an SMTP server — or a connection between the email server and the email client.
To establish the connection and start the email sending process, the SMTP client sends a predefined text-based command called HELO to the SMTP server. When it receives the TCP connection from a client, the SMTP process starts a connection through a port, usually port 25, to send the email. From here, the client tells the server what to do by providing information such as the sender’s and recipient’s email addresses and the email’s content. It also informs the server when transmission of data is complete, at which point the server closes the connection.
A mail transfer agent (MTA), which is a specialized program run by the server, then checks whether both email addresses are from the same email domain.
- If they are from the same domain, the email is sent directly to the recipient.
- If they are not from the same domain, the server queries the Domain Name System (DNS) to identify the recipient’s domain and Internet Protocol (IP) server, and then sends the message to the correct server.
This server might or might not be the email’s destination. If it is, the recipient then uses IMAP or Post Office Protocol 3 (POP3) to receive the email. But if it’s not, the SMTP connection process repeats between multiple email servers until the email reaches a server controlled by the recipient’s email provider. At this point, it reaches the recipient’s inbox.
What is an SMTP server?
An SMTP server is an application or computer that sends, receives and relays emails to their appropriate destinations. Here are the steps to set up an SMTP server, also known as an outgoing mail server:
- Appropriate SMTP server software must be configured on a computer, on a server or in the cloud.
- The server’s address, port number and security protocols must be configured.
- DNS settings must be configured.
- Firewall rules must be set up to prevent email delivery problems.
All network-connected devices come equipped with standardized ports that have an assigned number, with each number reserved for certain protocols and their associated functions. The port number identifies specific processes when an internet or network message is forwarded to a server.
Port 25 is usually reserved for SMTP. SMTP can also use ports 465 or 587 if port 25 is blocked to keep out scammers, who commonly abuse the port to send email spam. If these ports are also blocked, SMTP can use port 2525. SMTP servers are set to an always-on listening mode. As soon as a server detects a TCP connection from a client, the SMTP process initiates a connection to port 25 to send the email.
Outgoing SMTP servers send messages for users. Email clients, which are used to read and send emails, must also have the IP address of the SMTP server. To handle issues such as spam, server administrators must control which clients can use the server. They can do this either by restricting users by their IP address or by implementing a system or command that requires client authentication.
SMTP commands
SMTP commands are text-based instructions that facilitate the entire SMTP process between email clients, email servers and MTAs. These commands are issued automatically, without the need for the end user to enter them.
The HELO command is the email client identifying itself to a server. It starts the SMTP connection between these two components of the SMTP process.
Other SMTP commands include the following:
- MAIL. This command initiates a message transfer and tells the SMTP server that a new transaction is starting and who is sending the email.
- RCPT. This command identifies the recipient’s email address.
- DATA. This command starts the data transfer between the client and server. Message contents are moved to the SMTP server.
- RSET. This command is used to abort the mail transaction and reset the SMTP connection without closing it. It is sent to the server, where all data about the email is removed.
- QUIT. Once the email is sent, the client sends this command to the server to close the connection.
SMTP and other protocols
SMTP is typically limited to and relied on to send email messages from a sender to a recipient. It is limited in its ability to queue messages at the receiving end. For this reason, it’s usually used with either POP3 or IMAP, which lets the user save messages in a server mailbox and download them periodically from a server.
SMTP is usually used with TCP to ensure reliable delivery of data packets and IP to get the contents of an email message to the right server.
An alternative to SMTP that’s widely used in Europe is X.400/X.500. When it was created, X.400 was intended to serve as the primary international protocol. Among most users, X.400/X.500 has been eclipsed by SMTP, but it is still used in the defense and telecommunications industries.
SMTP vs. IMAP and POP
SMTP is used to send, relay or forward messages from a mail client and isn’t used to receive messages, deliver messages to their final destination or display them to users. For these functions, IMAP and POP are used instead. When used together, SMTP and either IMAP or POP transmit email messages.
IMAP is a standard email retrieval protocol that manages and retrieves email messages. It keeps an email on a server and then synchronizes it across different devices. IMAP functions as the intermediary between the email server and email client. When users read an email using IMAP, they read it off the server. They don’t download or store the email on their local device.
The IMAP protocol enables users to organize messages into folders, flag messages and save draft messages on the server. Users can also have multiple email client applications that sync with the email server to consistently show which messages are read or unread.
Most email servers and clients also support POP and use it to receive emails from remote servers and send them to a local client. POP is a one-way client-server protocol in which emails are received and held on the email server. POP also enables users to download emails from a server to the client so that the recipient can view the email offline.
While POP is considered a store-and-forward service, IMAP is thought of as a remote file server, because the user can store the email on the server and access it from any device or location as needed. Also, unlike POP, IMAP synchronizes emails across multiple devices or clients. That said, both POP and IMAP are supported by modern email clients and web servers.
SMTP vs. ESMTP
Extended Simple Mail Transfer Protocol (ESMTP) is an extension to the original SMTP for sending emails that support graphics, audio and video files, as well as text in various languages. ESMTP was released in 1995 for users who wanted to attach multimedia files to emails. The updated protocol enabled newer functions like protecting servers while saving bandwidth. Today, almost all commercial email servers and clients support ESMTP.
Unlike with ESMTP, multimedia files cannot be directly attached to an email in SMTP without the help of Multipurpose Internet Mail Extensions, or MIMEs. Likewise, ESMTP enables users to reduce the size of emails, while SMTP doesn’t.
Another key difference between SMTP and ESMTP is that ESMTP includes additional commands. One example is the EHLO command that enables ESMTP use when the connection is first established between the email client and mail server.
SMTP vs. HTTP APIs
SMTP has been used since 1982 and remains the most common email protocol to send an email message. However, in recent years, there has been a trend toward using cloud-based HTTP application programming interfaces (APIs) to send and receive email.
HTTP APIs offer several advantages. First, the communication between email client and server — for example, when using mobile apps — is faster than SMTP because HTTP APIs require fewer back-and-forth commands to authenticate the sender and recipient.
Additionally, APIs offer functionality that isn’t available with SMTP. For example, APIs include built-in HTTP capabilities to pass parameters and for authentication purposes. Also, transactional emails, such as purchase confirmations or emails, can be sent automatically and in response to specific triggers without the need for queuing.
Finally, APIs provided by third parties minimize the load on email servers. They are also easy to integrate, reducing the burden of maintenance on email providers and reducing email app complexity.
Some SMTP APIs can also do the following:
- Indicate errors with standard HTTP response codes.
- Report event data associated with specific emails, such as opens, clicks and click-to-open ratios.
- Support request libraries in multiple programming languages to facilitate ease of use for developers.
SMTP and Unix-based systems
On Unix-based systems, Sendmail remains one of the most widely used SMTP mail servers. In addition to accepting outgoing email messages and sending them on to the defined recipients, Sendmail is capable of queuing messages if a recipient is not immediately available. It also offers authentication to prevent — or at least minimize — spam, and can be used with Secure Sockets Layer, or SSL, to safeguard email messages from man-in-the-middle attacks.
Sendmail provides behind-the-scenes email transport. It is typically used to deliver preformatted messages, which means a separate user-friendly interface or front end is required.
In-house SMTP servers vs. third-party services
SMTP servers can be set up in-house or as a third-party service.
In-house SMTP servers run independently, while a provider runs third-party SMTP servers. Third-party SMTP vendors take care of everything from maintenance and monitoring of email servers to security. This means users don’t need the expertise or budget to run and maintain their own in-house server. However, users still must be concerned about downtime caused by outages or any additional terms and conditions.
In-house SMTP servers aren’t limited to only sending a specific number of emails per day, as some third-party providers might be. However, users must have the technical knowledge and budget to maintain, run and monitor the server. Additionally, users are responsible for implementing their own security. This could include selecting secure email protocols, keeping server firmware up to date or using email server firewalls.
SMTP vendors
Examples of SMTP service providers include the following:
- Amazon Simple Email Service. Amazon SES is a cloud-based SMTP service that enables marketers and developers to automatically send targeted marketing and transactional email campaigns and newsletters. It provides an SMTP interface and an API, and the messages can be sent from within any application. SES also provides sender statistics and email deliverability tools, plus IP management capabilities to help senders boost their trustworthiness and reach more users’ inboxes.
- Brevo. This SMTP service, previously called Sendinblue, supports transactional emails and bulk email marketing with its dedicated infrastructure and technical resources, including SMTP plugins and a free transactional email API. Its dedicated SMTP server supports high-volume email sends and free email testing. With this service, marketers can send up to 300 emails a day for free.
- SendGrid. This cloud-based SMTP email platform is suitable for companies looking to send transactional and marketing emails at scale. SendGrid provides numerous email deliverability tools and templates to streamline the email send process, along with email analytics and seamless integration with other apps and platforms through an API.
- SendLayer. This transactional email provider offers an API and SMTP relay to maximize the reliability and deliverability of many types of email messages, including transactional emails, confirmation emails and shipping notifications. The service includes open and click analytics, support for SMTP and API credentials, and detailed email logs to track sent and bounced emails.
The pricing models for these services differ by vendor, as some offer a monthly price for a specific number of emails users can send, while other vendors offer paid plans per month or pay-as-you-go models. Free versions of each SMTP tool might also be available, but are normally limited by the number of emails users can send.
Learn more about SMTP and its functions, along with 11 other common network protocols.
#SMTP #Simple #Mail #Transfer #Protocol