### [A Beginner's Guide to SMTP: What It Is and How It Works](https://wpmailsmtp.com/what-is-smtp-how-it-works/)

**Published:** August 20, 2024
**Author:** Rachel Adnyana

**Excerpt:** SMTP is essential for reliable email delivery, but what is SMTP exactly? In this beginner's guide, learn all about how SMTP works to route your emails efficiently and securely and why it's a better option than the built-in PHP mail() function in WordPress.

Find out about SMTP servers, ports, and why implementing an SMTP plugin like WP Mail SMTP is crucial to improve your email deliverability and ensure important messages reach your users' inboxes.

**Content:**

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.

[Fix Your WordPress Emails Now](https://wpmailsmtp.com/pricing/)

## What is SMTP?

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.

![Postman Delivers Emails](https://wpmailsmtp.com/wp-content/uploads/2024/08/postman-delivering-emails.jpg)

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.

![How WP Mail SMTP works](https://wpmailsmtp.com/wp-content/uploads/2021/01/wpmailsmtp-how-it-works.png)

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](https://wpmailsmtp.com/choosing-the-right-smtp-provider-for-your-wordpress-site/).

#### 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.

![How SMTP Works](https://wpmailsmtp.com/wp-content/uploads/2024/08/how-smtp-works.png)

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](https://wpmailsmtp.com/what-to-do-if-your-smtp-server-goes-down/). This step may involve passing through several intermediate servers (relays) before reaching the final destination.

![How Email Authentication Works](https://wpmailsmtp.com/wp-content/uploads/2024/08/email-authentication.png)

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 CodeClassDescription2xxSuccessThe requested action has been successfully completed211SuccessSystem status or help reply214SuccessHelp message220SuccessService ready221SuccessService closing transmission channel250SuccessRequested mail action okay, completed251SuccessUser not local; will forward252SuccessCannot verify user, but will attempt delivery354SuccessStart mail input; end with <crlf>.<crlf>4xx Falha temporária O comando não foi aceite e a ação solicitada não ocorreu 421 Falha temporária Serviço indisponível, a fechar o canal de transmissão 450 Falha temporária Ação de correio solicitada não executada: caixa de correio indisponível 451 Falha temporária Ação solicitada abortada: erro local no processamento 452 Falha temporária Ação solicitada não executada: armazenamento insuficiente no sistema 5xx Falha permanente O comando não foi aceite e a ação solicitada não ocorreu 500 Falha permanente Erro de sintaxe, comando não reconhecido 501 Falha permanente Erro de sintaxe nos parâmetros ou argumentos 502 Falha permanente Comando não implementado 503 Falha permanente Sequência incorreta de comandos 504 Falha permanente Parâmetro de comando não implementado 521 Falha permanente O servidor não aceita correio 550 Falha permanente Ação solicitada não executada: caixa de correio indisponível551Falha permanenteUtilizador não local; por favor, tente <forward-path>552Permanent FailureRequested mail action aborted: exceeded storage allocation553Permanent FailureRequested action not taken: mailbox name not allowed554Permanent FailureTransaction failedIf 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](https://wpmailsmtp.com/best-smtp-servers/) 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 versionsMailers in [WP Mail SMTP Pro](https://wpmailsmtp.com/pricing/)[SendLayer](https://wpmailsmtp.com/docs/how-to-set-up-the-sendlayer-mailer-in-wp-mail-smtp/)[Amazon SES](https://wpmailsmtp.com/docs/how-to-set-up-the-amazon-ses-mailer-in-wp-mail-smtp/)[SMTP.com](https://wpmailsmtp.com/docs/how-to-set-up-the-smtp-com-mailer-in-wp-mail-smtp/)[Microsoft 365 / Outlook.com](https://wpmailsmtp.com/docs/how-to-set-up-the-outlook-mailer-in-wp-mail-smtp/)[Brevo](https://wpmailsmtp.com/docs/how-to-set-up-the-sendinblue-mailer-in-wp-mail-smtp/)[Zoho Mail](https://wpmailsmtp.com/docs/how-to-set-up-the-zoho-mailer-in-wp-mail-smtp/)[Google Workspace / Gmail](https://wpmailsmtp.com/docs/how-to-set-up-the-gmail-mailer-in-wp-mail-smtp/)[Mailgun](https://wpmailsmtp.com/docs/how-to-set-up-the-mailgun-mailer-in-wp-mail-smtp/)[Postmark](https://wpmailsmtp.com/docs/how-to-set-up-the-postmark-mailer-in-wp-mail-smtp/)[SendGrid](https://wpmailsmtp.com/docs/how-to-set-up-the-sendgrid-mailer-in-wp-mail-smtp/)[SparkPost](https://wpmailsmtp.com/docs/how-to-set-up-the-sparkpost-mailer-in-wp-mail-smtp/)[Other SMTP](https://wpmailsmtp.com/docs/how-to-set-up-the-other-smtp-mailer-in-wp-mail-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](https://wpmailsmtp.com/wordpress-not-sending-email/) 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](https://wpmailsmtp.com/email-deliverability-beginners-guide/).
- **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](https://wpmailsmtp.com/docs/configuring-backup-connection/) and [smart email routing](https://wpmailsmtp.com/docs/setting-up-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](https://wpmailsmtp.com/dmarc-spf-dkim/)) 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.

[Fix Your WordPress Emails Now](https://wpmailsmtp.com/pricing/)

### 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](https://wpmailsmtp.com/pricing) 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.

**Categories:** Marketing

**Tags:** smtp, transactional email, wordpress email, WordPress email deliverability, wordpress smtp

---

