Hundreds of billions of emails get transferred daily because of their worldwide popularity as a reliable communication medium. But have you ever considered how your email messages reach the intended recipient once you send them?
This article will introduce one of the methods used to transfer emails: SMTP, and its key concepts.
What Is SMTP?
SMTP, Simple Mail Transfer Protocol, is a collection of communication guidelines for sending emails over the internet. SMTP is among the most widely used email protocols, along with protocols like IMAP (Internet Message Access Protocol) and POP (Post Office Protocol). Most famous email clients, such as Outlook, Gmail, and Apple Mail, support SMTP email protocol for message sending.
What Is an SMTP Server and Why Do We Use It?
SMTP is the protocol that defines the rule set for digital communication, whereas the SMTP server is the application that handles the email sending, receiving, and relaying processes. Therefore, it is crucial to have an SMTP server for the email to reach its destination.
There are two types of SMTP servers:
- Normal servers
- SMTP proxy servers
There are many email service providers that we can use for business communication and day-to-day emailing. But SMTP server is a better solution as it addresses most of the limitations of those email service providers.
For example, dedicated SMTP servers can handle bulk emails and are scalable.
How Does SMTP Fit in with Other Email Protocols?
Along with SMTP, the two other most commonly used email protocols are IMAP and POP. However, several factors make SMTP different from these two email protocols.
- A significant difference is that SMTP is for sending data ("push" emails from an unknown email server to another), whereas POP and IMAP are for retrieving messages ("pull" from their email server).
- The email transference in IMAP and POP is limited to working only with verified mail servers.
Read more: IMAP vs. POP3 vs. SMTP
Advantages of Using an SMTP Server
- Regular SMTP server supports both inbound and outbound email delivery.
- The users can have a dedicated server if needed.
- It supports bulk mailing.
- Low cost and extended area coverage.
- Provide options for tracking emails.
- Reliable and quick email delivery.
How Does SMTP Work?
The following steps describe how email transfer happens with SMTP.
- Email clients can connect and communicate with a server once the server is established. Then, the email client opens this connection to the server to send an email when the user clicks the "send" button in the email client interface.
- Using the SMTP commands (discussed later), the SMTP client tells the server what to do and where to transfer the data.
- Afterward, the MTA (Mail Transfer Agent) checks the domains of both sender and recipient email addresses, and if it is the same, the message is sent right away. On the other hand, if the domains differ, the server sends the email to the correct server using DNS (Domain Name System).
SMTP Ports - What You Need To Know
We can use multiple SMTP ports as communication endpoints to send our emails over a network.
- Ports 25, 467, 587, and 2525 are suitable for standard use. However, port 467 is out-of-date.
- Even though port 25 is the primarily used port for SMTP relay, it often gets blocked by cloud service providers and ISPs.
- While port 587 continues to be the best for modern apps, 2525 works as an alternative if the standard ports are unavailable.
Basic SMTP Commands
SMTP uses a set of commands to power the transmission between servers to deliver emails. Each of these commands composes of one keyword followed by one or more arguments.
Below are ten critical commands you should know when working with SMTP.
1. HELO - It is the first and most essential STMP command as this starts the email sending processor and identifies the sender server. "EHLO" is another alternative command to initiate a conversation.
2. MAIL FROM - States the sender's email address and indicates a new email transference is about to happen to the SMTP server. If the server accepts this transaction, it will respond with status code 250.
3. RCPT TO - Specifies the email recipient, and command repetition allows adding more recipients one by one.
4. SIZE - Informs the remote server about the size of the email in bytes.
5. DATA - The email content starts transferring to the SMTP server, and the server responds with a 345 reply code.
6. VRFY - This command is to verify whether a particular username or email address exists.
7. AUTH - A command to extend the security by authenticating the client to the server using the username and password.
8. TURN - Reverse the roles of the client and the sender without using a new connection.
9. QUIT - This is a mandatory command to terminate the connection after sending the email.
10. RSET - We can use this command to abort the current email transaction if there is an error. For instance, terminate the process without closing the connection if you accidentally gave an incorrect recipient email.
Understanding SMTP Error Codes
Several situations like blocks and bounces can fail the email sending process. So, the receiving server uses the SMTP error codes to indicate such errors. Therefore, it is crucial to understand these error codes to identify and fix the issues.
- If the error code starts with "4," followed by two other numbers, it probably indicates a temporary failure associated with the receiving server. Most of the time, trying again will complete the transaction. Example: 421 (service unavailable, try again later), 452 (server storage limit exceeded)
- If the error code starts with "5," followed by two other numbers, it indicates a permanent error that cannot be solved by trying again. Example: 500 (syntax error in the command), 541 (the recipient rejected the message)
Types of SMTP Servers
Normal Server: This regular SMTP server is to acknowledge and queue emails to deliver. This server allows both inbound and outbound email delivery, and it is necessary to specify the local domains handled by the server. If an email comes from an alternate domain, it is sent to the destination if relaying is allowed.
SMTP Proxy Server: A proxy server is not entirely an SMTP server. It needs another actual SMTP server to connect to and has the capability of monitoring emails, altering content, and even blocking unnecessary emails. The users can use proxy servers only for inbound email delivery.
SMTP Relay Vs. SMTP Server: The SMTP server is the server where a mail client connects to send emails, whereas the SMTP relay passes the emails coming from other servers to the correct SMTP server.
Running Your Own SMTP Server vs Using a Third-Party Email Service: What’s Better?
1. Running Your Own SMTP Server
- Can monitor all the delivery information.
- No limit on the number of emails to send per day/hour.
- Your email list information is secure.
- Vulnerable to connection issues and power outages as the server is local.
- It can cost more money and is time-consuming.
- Have to pay extra attention to security.
2. Using a Third-Party Email Service:
- Secure than running your own server.
- Less technical knowledge is required.
- More reliable deliverability.
- Have to rely on a third-party company for support if any issue arises.
- Have to face limitations.
- Have to abide by the terms and conditions of the company.
Determining whether to use your own server or a third-party email server depends on the resources and requirements.
Frequently Asked Questions
Which ports does SMTP use?
Port 25 (standard), 587, 465, and 2525 (non-standard alternative)
What SMTP port is used by Gmail?
Port 465, port 587, if the client starts with plain text before issuing the STARTTLS command.
What is the default port for SMTP?
Is SMTP encrypted?
SMTP lacks encryption by default.
Is SMTP secure?
SMTP is not exactly secure and is susceptible to attacks. So, we can use SMTPS (Simple Mail Transfer Protocol Secure) to secure the email communication.
Is SMTP more secure than IMAP?
IMAP is marked secure compared to SMTP but lacks security features by default. But IMAP is also vulnerable to attacks as it transmits credentials in plain text.
What does SMTP stand for?
Simple Mail Transfer Protocol
Is SMTP inbound or outbound?
The regular SMTP server support both inbound and outbound email delivery, whereas the SMTP Proxy server supports only inbound.
Is SMTP needed for a web server?
SMTP is essential for sending emails. If not, the emails will not reach the intended destination.
How to test if SMTP is working?
Open the command prompt and type 'telnet,' the SMTP address, and the port address in the format 'telnet smtp.sample.com 25'. If the server is working, a 220 status code returns.