SMTP may seem complicated with its protocols, ports, servers, and providers, but it doesn’t need to be. We’re covering it all to help you fully understand SMTP.
What Is Simple Mail Transfer Protocol?
Simple Mail Transfer Protocol (SMTP) is the protocol used by email servers to send, receive, or relay outgoing mail between users.
SMTP is one of the core technologies behind email, yet many of us do not know much about it. If you have ever configured an email client application on your computer (like Outlook, Thunderbird, Apple Mail, or Windows Mail), then you are more likely to have encountered SMTP at least once.
How Does SMTP Work?
Simple Mail Transfer Protocol (SMTP) is a protocol used to transmit email messages from one server to another. SMTP works by sending messages through a series of commands and responses. A client machine sends an SMTP command to a mail server, which is then responsible for relaying the message to the intended recipient. This process typically involves authentication and encryption, depending on the email provider. After a successful authentication and encryption, the server forwards the message to the recipient’s mail server, which then delivers the message to the recipient’s inbox.
Let’s distinguish two important terms before discussing SMTP in detail:
- Email servers are pieces of software on a computer that handle the routing, sending, and receiving of mail. These servers can run on any computer (so long as they are designed for a given operating system) and will handle operations without manual control from an administrator.
- Email clients are stand-alone pieces of software that can connect to servers and use them locally on a user’s machine. When using a client, you aren’t sending an email directly from your computer. Instead, you are using local tools (processing, formatting, etc.) and then sending the email through a different server, which handles routing.
It is important to understand that transactions occur through what’s known as an SMTP server, which is part of a more comprehensive server. For example, you could have a dedicated computer that serves only as a server or run the software on a multipurpose computer. An SMTP server would potentially be part of that software.
In either case, the “SMTP” part of email controls incoming and outgoing mail through a few basic mechanisms. These mechanisms include the following:
- An SMTP Server: You must have a software platform installed and running on your computer to send and receive messages. This server must be configured to accept and send email. Furthermore, an email client connecting to that software must know those configuration details.
- An SMTP Server Location: Dedicated servers will often have an address used to connect to that server. For example, you can use a client to connect to Google servers at smtp.google.com and send mail using that email server.
- Dedicated Port Connections: The email server will dedicate one or more ports, network connections represented numerically in your computer system, exclusively to send and receive email. Commonly, servers will default to ports 25 for plaintext emails and 587 for encrypted emails.
What Are SMTP commands?
SMTP commands are a set of instructions used to control the communication between email servers. They are used as part of the SMTP (Simple Mail Transfer Protocol) which allows emails to be sent, received, and relayed between servers. Some of the most common SMTP commands include HELO, EHLO, MAIL FROM, RCPT TO, DATA, QUIT, and RSET . These commands are used to identify the sender and recipient of an email, send the message content, terminate a session, and reset an existing session. Let’s take a closer look:
- HELO or EHLO: When SMTP sends a message it connects to a receiving server, it identifies itself as a server (and thus capable of exchanging emails) using this command. The sending computer provides the HELO command, and the receiving computer sends another HELO command back with IP address or domain information.
- MAIL FROM: This includes information about who the message is from and signals that an email transaction is beginning. Once accepted, the receiving computer takes the MAIL FROM address and sends an OK reply code.
- RCPT TO: Following the OK code, the sending computer provides this command that outlines the email address the message is intended for. This process can continue multiple times if there are multiple recipients.
- DATA: Once the recipients are all logged, the sending computer will then transfer message contents to the receiving server. The sending computer will end a transmission with a single line containing a single dot, signaling the end of transmission, and the receiving computer will signal with an OK command. After that OK command, the receiving server will send the message to the email addresses from the RCPT TO command.
- QUIT: The sending computer sends this command to end the transmission.
While this seems like a cumbersome process, especially for millions of emails per day, the truth is that each command only takes a fraction of a second.
We mentioned that SMTP uses plaintext to send information. There is an extension of SMTP, called Simple Mail Transfer Protocol Secure (SMTPS), that uses SSL or TLS for encryption rather than connecting through TCP. Many providers, like Google, will default to TLS so long as both sender and receiver also use TLS. Otherwise, they will send the email unencrypted.
What port does SMTP use?
SMTP uses a specific port for communication, which is port 25. This port is used for exchanging emails between the server and the email client. It is also used for relaying emails from an email server to another. It helps to ensure that the emails are delivered successfully, as it regulates the amount of data sent over the network and helps to reduce potential risks of data being lost or corrupted.
Understanding SMTP error codes
When an email is not successful, it can return an error code containing a specific meaning. Error codes usually have three digits, and each digit has a different meaning. The first digit indicates whether the email was accepted or rejected. The second and third digits identify the type of error.
For example, if an email is rejected with error code 451, the first digit (4) indicates that the email was rejected. The second and third digits (51) indicate that the email was rejected because the server is unable to accept the message. In other words, the email is not accepted due to temporary problems.
Other common error codes are 500 and 503, which mean that the email could not be sent due to a server error and a server issue, respectively. 550 codes indicate that the recipient’s mailbox does not exist and 554 codes indicate that the email is identified as spam.
What is an SMTP envelope?
An SMTP envelope is a set of information that is sent along with an email message, but is not visible to the recipient. It includes details such as the sender, recipient, and the path that the email will take from sender to recipient, and it is used to enable email programs to properly handle the email. The envelope is also used to help trace emails in case of suspected fraud or abuse.
What Are the Differences Between SMTP, POP, and IMAP?
SMTP is not the only protocol in use throughout the world. Most email servers and providers will also implement additional protocols to handle different types of usage. Two of the most common protocols are Post Office Protocol (POP) and Internet Message Access Protocol (IMAP).
What are the differences between these three protocols?
- Pushing vs. Pulling: SMTP can handle sending, receiving, and routing mail between servers—even unknown servers. This means that SMTP is the foundational protocol that connects emailers across the world. POP and IMAP, however, handle “pulling” emails from one computer to another. For example, a client connected to a server can use the SMTP component of that server to send and receive emails, but it uses either POP (currently POP3) or IMAP to pull emails to the local machine to store and read.
- Downloading vs. Syncing: Connecting a client to a server via POP sets up a system where the client will establish a single connection to the server, download all available emails, and store them locally in the user’s machine. IMAP will do the same, but because IMAP functions as a cloud service, it supports syncing of your server configuration across multiple devices—web interfaces, mobile clients, and computer clients. Any change on one device will sync across multiple devices. This is the most commonly used email protocol for pulling emails today.
Is SMTP Secure?
SMTP is not inherently secure, as it does not utilize any form of encryption to secure data in transit. This means that any data sent over the protocol can be intercepted and seen by third parties. To provide a secure connection over SMTP, additional measures such as encryption or authentication should be used.
What is an SMTP injection attack?
An SMTP injection attack is an unauthorized attack on an email server in an attempt to manipulate the server to send malicious emails or gain access to confidential information. The attacker injects malicious code into the Simple Mail Transfer Protocol (SMTP) conversation between two mail servers to control the conversation and allow them to manipulate the server. This can be used to gain access to authentication credentials, send malicious emails, and gain access to restricted areas of the server.
How to Make SMTP Secure With SSL/TLS
To make SMTP secure, you can use TLS (Transport Layer Security). TLS is a cryptographic protocol that helps secure emails by encrypting emails sent through SMTP. You can also use STARTTLS, which is an option within SMTP that allows the server to upgrade an otherwise insecure connection to a secure one. Additionally, you can use a different port for secured SMTP communication, like port 465 instead of port 25. This will make sure that all emails are sent securely through the SMTP server.
What Are the Benefits and Challenges of Using SMTP Servers?
Like any technology, using SMTP (or deploying your own servers) can present challenges even as they provide significant benefits.
Some of the primary benefits and challenges of using or deploying your own server include the following:
- No Volume Limits: Owning and operating your own server can free you from constraints that ISPs place on email volume. If you operate marketing or other services, this could help you better manage your email volume.
- Monitoring and Privacy: You control ongoing monitoring, security, and privacy. Your data is secure, your email lists remain private, and you can have more say in compliance and security measures.
- Costs: Setting up, deploying, managing, monitoring, and maintaining a server can become costly, especially if you have to hire any staff to manage configurations and technical issues. This is especially true if you have any compliance requirements or security needs that call for extensive technical expertise.
- Local and Vulnerable: Unless you have backup cloud services for email, your server is vulnerable to shutdown. Power loss, hacks, or other network problems could knock out your entire email system.
Running Your Own SMTP Server vs. Using a Third-party Email Service
Very few organizations manage their own email these days. This is because third-party servers have huge benefits over on-premises solutions:
- More Cost-efficient: Managed servers are, generally, much cheaper to purchase and use than on-premises solutions. That’s because vendors distribute costs over multiple vendors and make managing dedicated email servers cheaper. Furthermore, you’re not spending money on dedicated IT teams just to manage email—a major way to reduce costs in terms of money and labor.
- Security, Privacy, and Compliance: While it might seem counterintuitive, having a third party manage your email services promotes better security practices. Since these parties are more focused and invested in a single set of priorities (namely, email and related technology), there is not an issue of lack of workforce or expertise.
- Reliability: System outages are not a major problem with a third-party provider. Yes, they still happen, but not at the same rate and not with the same ramifications. Even with system outages, most providers will have backups and redundancies to keep the service up and running.
The only major drawback of using a third-party email provider is that you do not control the servers and implementation. This means that you may not have the same configurations, backups, or compliance practices that you would in-house.
How Do I Know if My Emails Are Using SMTPS?
You can check the security settings of your email account or the email program you are using. If your emails are using SMTPS, this will be indicated in the security settings. You may also be able to see this information in the headers of the emails you send. If you are unsure if your emails are using SMTPS, you can seek advice from your email provider or system administrator.
What Is Extended SMTP (ESMTP)?
Extended SMTP (ESMTP) is an improved version of the original Simple Mail Transfer Protocol (SMTP). It is an extension of the SMTP protocol and is used to facilitate the transfer of emails, between internet users and mail servers. The purpose of ESMTP is to increase the number of commands included in SMTP in order to address a wider range of email functions, including authentication and enhanced message size.
ESMTP improves security by introducing support for authentication. It allows you to identify the sender of a message and to ensure that the messages sent are from the intended source. With ESMTP, a mail server can reject a message if it fails to authenticate the sender.
The increased support for message sizes with ESMTP allows for large message bodies and attachments to be transferred without crashing the server. This helps to reduce the burden on mail servers and decreases the chances of any messages being lost in transit.
ESMTP also helps to improve email reliability by reducing the chances of failed deliveries. If a message fails to be sent the first time, servers can attempt to re-send it, without the user having to resend their message.
Want to Learn More About SMTP?
SMTP is the core of email communication. With the foundation of SMTP, engineers have developed rich text and HTML emails, cross-platform email access for mobile, web, and desktop users, and even the ability to embed media into an email safely.
If you want to learn more on how Kiteworks employs SMTP, schedule a custom tailored demo with our team.
Get email updates with our latest blogs news