WP Mail SMTP is a plugin that can significantly improve your WordPress site’s email functionality. Once installed, it replaces the default PHP mail() function with SMTP for sending emails. This change leads to more reliable and secure email delivery from your WordPress site.
But what exactly is SMTP? How does it work, and why is it superior to the built-in PHP mail() function?
In this guide, I’ll break down SMTP for you in clear, straightforward terms. By the end of it you’ll know exactly what SMTP is, how it routes your email safely and securely, and why using an SMTP plugin on your WordPress Site is a must.
What is SMTP?
In This Article
Simple Mail Transfer Protocol (SMTP) is a way for sending mail servers, receiving mail servers, and message transfer agents to communicate.
You can think of it as a language that tells a mail server where to send a message, what’s in the message, and if there are any attachments. It also tells mail servers what to do if the email can’t be delivered.
Think about the options you have when you want to send a letter to someone. You can send it by the local postal service, or by various private couriers. In the real world, these different mail services all act like various mail “protocols” – each one has its own methods for delivering messages and deciding what to do if the recipient isn’t at the stated address or refuses the letter.
SMTP happens to be one of the fastest and most reliable ways to deliver your emails. If it was a courier in the real world, it would be the gold standard of message delivery, ensuring your important emails reach their destination safely and securely.
Let’s take a closer look behind the scenes at what happens when your website sends an email.
How WP Mail SMTP Works
Here’s what happens once you click the “send” button on your email or your WordPress site sends an email via an SMTP plugin like WP Mail SMTP:
1. Triggering the Email
First, an action on your website triggers the need to send an email. This could be a new user registering, someone filling out a contact form, or an order confirmation.
2. WP Mail SMTP Takes Over
Instead of using the default WordPress email function (which often has deliverability issues), the WP Mail SMTP plugin steps in to handle the email delivery.
The plugin reconfigures the wp_mail() function to use a proper SMTP server instead of the standard PHP mail function.
3. Choosing the SMTP Service
WP Mail SMTP sends the email through the SMTP service you’ve configured in the plugin settings. This could be your hosting provider’s SMTP server, or a third-party service like SendLayer, Gmail, or another email service provider.
4. Authenticating the Email
The plugin authenticates the email using your SMTP service credentials. This step ensures that the email is sent securely and is less likely to be marked as spam.
Authentication involves logging into the SMTP server with the username and password you provided.
5. Sending the Email
Once authenticated, the SMTP server processes the email and sends it out to the recipient’s email server.
The email is now on its way to the recipient, passing through various checkpoints to ensure it’s delivered successfully.
6. Recipient’s Email Server Receives the Email
The recipient’s email server receives the email and places it in the inbox (or, in some cases, the spam folder if there are issues like poor sender reputation).
If everything goes well, the recipient will see the email in their inbox.
7. Delivery Confirmation (Optional)
Depending on your SMTP service and settings, you might receive a delivery confirmation or log entry showing that the email was successfully sent.
And that’s it! WP Mail SMTP helps ensure that your emails are properly authenticated and delivered, reducing the chances of them ending up in spam.
How Does SMTP Work?
WP Mail SMTP and other SMTP plugins do the job of getting the email from your site to the outgoing mail server (SMTP server). But what happens then?
As SMTP is a protocol (you can think of it like a language), it lets you send email from any type of hardware or software to any other device.
You can send email from an iPhone to a PC, a website to an app, or from a MacBook to your printer. Because all these devices “speak” and understand the SMTP protocol, they’ll know what to do with your email.
1. Connecting to the SMTP Server
The email client (which could be an application, website, or software like WP Mail SMTP) connects to the SMTP server and introduces itself with something called a “handshake”, which is essentially saying, “Hello, I want to send an email.” The server responds with its own greeting, confirming it’s ready to proceed.
2. Authentication
The client logs in to the SMTP server using a username and password to ensure the email is sent securely.
The server checks the credentials. If they are correct, the server responds with a success message, allowing the client to proceed. If not, the connection is terminated or the client is asked to reauthenticate.
3. Sending the Email
The client tells the server who the email is from and who it’s going to. The server checks each recipient’s address to ensure it can deliver emails to those addresses.
The client then sends the full email content, including any attachments, to the server. Upon receiving the full message, the server acknowledges the end of the data transfer and confirms whether the email has been accepted for delivery.
4. Routing the Email
The SMTP relay processes the email and forwards it to the recipient’s email server, finding the correct path by performing a DNS lookup to find the recipient’s mail server address (MX record). This works similarly to looking up a phone number in a directory.
The email is then forwarded to the recipient’s SMTP server for delivery. This step may involve passing through several intermediate servers (relays) before reaching the final destination.
As emails pass through various servers, they might be checked by spam filters, which evaluate factors like sender reputation, content analysis, and authentication protocols like SPF, DMARC, and DKIM to determine if the email is legitimate.
6. Delivery
The recipient’s SMTP server receives the email. Once the receiving mail server accepts the email, there are other protocols that work to retrieve the emails from the server and deliver them to your inbox.
POP3 downloads messages directly from the mail server to your device while IMAP also retrieves the message but leaves a copy on the server.
The SMTP server responds with a confirmation, closes the connection, and the email transaction is complete.
7. Error Handling
If any issues occur during the process (e.g., invalid recipient address, server unavailability, etc.), the server returns SMTP error codes to the client. The client may attempt to resend the email or notify the sender of the failure.
Error Code | Class | Description |
---|---|---|
2xx | Success | The requested action has been successfully completed |
211 | Success | System status or help reply |
214 | Success | Help message |
220 | Success | Service ready |
221 | Success | Service closing transmission channel |
250 | Success | Requested mail action okay, completed |
251 | Success | User not local; will forward |
252 | Success | Cannot verify user, but will attempt delivery |
354 | Success | Start mail input; end with <CRLF>.<CRLF> |
4xx | Temporary Failure | The command was not accepted, and the requested action did not occur |
421 | Temporary Failure | Service not available, closing transmission channel |
450 | Temporary Failure | Requested mail action not taken: mailbox unavailable |
451 | Temporary Failure | Requested action aborted: local error in processing |
452 | Temporary Failure | Requested action not taken: insufficient system storage |
5xx | Permanent Failure | The command was not accepted and the requested action did not occur |
500 | Permanent Failure | Syntax error, command unrecognized |
501 | Permanent Failure | Syntax error in parameters or arguments |
502 | Permanent Failure | Command not implemented |
503 | Permanent Failure | Bad sequence of commands |
504 | Permanent Failure | Command parameter not implemented |
521 | Permanent Failure | Server does not accept mail |
550 | Permanent Failure | Requested action not taken: mailbox unavailable |
551 | Permanent Failure | User not local; please try <forward-path> |
552 | Permanent Failure | Requested mail action aborted: exceeded storage allocation |
553 | Permanent Failure | Requested action not taken: mailbox name not allowed |
554 | Permanent Failure | Transaction failed |
If the email cannot be delivered after several attempts, the SMTP server may generate a bounce message (permanent failure), which is an automated response sent back to the original sender, explaining why the email couldn’t be delivered.
What Is an SMTP Server?
An SMTP server, also known as an outgoing mail server, is the system that manages all your outgoing emails and makes sure they’re routed to the right place.
In other words, your SMTP server acts like your local post office. You can safely leave your messages there with the address of the intended recipient and trust they’ll be delivered quickly and to the right place.
WP Mail SMTP allows you to use any SMTP server for delivering your emails. We recommend services like SendLayer, SMTP.com, and Brevo for their reliability, security, and scalability but you can use any mail provider’s SMTP service. Even free email providers like Gmail use SMTP to deliver emails.
You can see our list of supported email services below:
Mailers available in all versions | Mailers in WP Mail SMTP Pro |
---|---|
SendLayer | Amazon SES |
SMTP.com | Microsoft 365 / Outlook.com |
Brevo | Zoho Mail |
Google Workspace / Gmail | |
Mailgun | |
Postmark | |
SendGrid | |
SparkPost | |
Other SMTP |
SMTP vs PHP Mail()
Let’s talk about how WordPress sends emails by default. It uses a function called wp_mail(), which uses the PHP mail().
This function takes the recipient, message, subject, and headers from the code snippet to create the email and your WordPress hosting provider then attempts to deliver the email.
While this function is pretty simple to use, it can cause some headaches when you’re trying to send emails from your site.
Firstly PHP mail() is not always reliable. Some hosting providers don’t even allow it because it can be a security risk and may be exploited by hackers and spammers. If this function is disabled, your email won’t even make it out of your website.
Even when it does work, emails sent this way often end up in spam folders or don’t get delivered at all. Why? Because they’re missing some important security checks that many email systems now expect. Plus, it’s prone to errors which can prevent your email from being sent or delivered correctly.
Now, let’s look at the difference between SMTP and PHP mail(). SMTP is a different way of sending emails that fixes a lot of these problems:
- SMTP routes your emails through specialized email servers (like SendLayer or Gmail), which are optimized for reliable email delivery.
- It supports protocols like SPF, DMARC, and DKIM, which verify your email’s legitimacy and improve email deliverability.
- Many SMTP services offer encryption (SSL/TLS) during transmission, enhancing security, especially for sensitive information.
- SMTP reduces the chances of technical errors that could prevent delivery.
- It often provides more detailed feedback on email delivery status, helping you identify and resolve issues.
While PHP mail() is the default in WordPress, it’s not always the best choice. SMTP is generally more reliable and secure and can really improve the deliverability of emails sent from your WordPress site.
And deliverability is crucial to make sure all those important site emails like order confirmations, password resets, and account updates reach their intended recipient. The
last thing you want is for your WordPress emails to be lost or delayed, which is why it’s so important to use an SMTP plugin like WP Mail SMTP
SMTP Email vs Email API
You may have noticed that WP Mail SMTP offers both SMTP and API setup options for different email services. Here’s a simple explanation of how they work:
SMTP is a reliable and widely used method for sending emails. When you connect to your email provider via SMTP, your emails are sent through an external email server using the method described above
API is a modern alternative that can be even easier to set up. With the API method, all you need is an API key from your email service provider.
Once you enter the key in WP Mail SMTP, the plugin connects directly to the email service’s server. This method is often faster and may provide additional features, like email tracking and analytics.
Both options are excellent for sending emails from your WordPress site, and WP Mail SMTP supports both methods, depending on which email service you are using.
SMTP Ports Explained
Ports help computers and other devices route network traffic to the correct applications.
You can think of network ports like doors on a building. Just like each door in a building leads to a different room, each port on a computer or device leads to a specific service or function.
When data is sent over the internet, it needs to know which “door” (or port) to enter so it can reach the correct program or service. For example, if you’re visiting a website, your request is sent to the port that handles web traffic.
Just like with other services, SMTP uses specific ports to handle email traffic. The main SMTP ports are:
- Port 25: This is the original port used for SMTP, mainly for relaying emails between servers. However, it’s often blocked by ISPs to prevent spam.
- Port 587: This is the most commonly used port for sending email from your email client to an email server. It’s preferred because it supports encryption, making your email more secure.
- Port 465: This port was originally assigned for SMTP with SSL encryption but was later deprecated. However, some servers still use it for secure email transmission.
When you set up WP Mail SMTP, it’s important to configure the correct SMTP port in your settings to make sure your email can be delivered. This information should be provided by your mail server along with your other account credentials.
Frequently Asked Questions about SMTP
Here are some of the most common questions we receive from users considering switching to SMTP for their email delivery method on their WordPress site:
Can I use multiple SMTP servers with WP Mail SMTP?
With WP Mail SMTP Pro, you can set up backup mailers and smart email routing. This means if your primary SMTP server fails, it can automatically switch to a backup to ensure your emails still get sent. You can also route emails through an alternate server based on variables such as subject, message content, sender, and the plugin that generated the email.
Will switching to SMTP affect my existing emails or email templates?
No, switching to SMTP only changes how your emails are sent, not their content. Your existing email templates and designs will remain the same. However, you might notice improved deliverability for your emails.
Can I track opens and clicks on emails sent via SMTP?
Basic SMTP doesn’t include tracking features. However, some email service providers offer these analytics when you use their API connection method in WP Mail SMTP. If email tracking is important to you, look for a provider that offers this feature.
What should I do if my emails still aren’t being delivered after setting up SMTP?
First, check your SMTP settings to ensure they’re correct. Then, verify your DNS records (SPF, DKIM, DMARC) are properly set up. If problems persist, check with your email service provider for any potential issues on their end.
Is there a limit to how many emails I can send through SMTP?
Email sending limits depend on your SMTP provider, not the SMTP protocol itself. Some providers have daily or hourly sending limits, especially on free plans. Check with your chosen provider for their specific limits.
Can I use my personal Gmail account as an SMTP server for my WordPress site?
While it’s possible to use a personal Gmail account if you want a free SMTP service, it’s not recommended for business websites due to lower sending limits. We advise using one of the recommended email providers in our list above.
How does SMTP handle email attachments?
SMTP can handle attachments, but large attachments might cause issues. Many SMTP servers have size limits for emails (often around 10-25MB). For larger files, consider using file sharing services and including a link in your email instead.
And that’s it! Now you understand what SMTP is and how it works to improve your email deliverability.
Next, Learn How To Troubleshoot WP Mail SMTP
Are you experiencing errors or other problems with using WP Mail SMTP? Check out our guide to common WP Mail SMTP issues for a simple guide to help you fix them and get your emails to send smoothly again.
Ready to fix your emails? Get started today with the best WordPress SMTP plugin. If you don’t have the time to fix your emails, you can get full White Glove Setup assistance as an extra purchase, and there’s a 14-day money-back guarantee for all paid plans.