Logo Supporthost

WordPress SMTP: how to send authenticated emails

February 21, 2023 / Published in:  from Ivan Messina
No comments

WordPress emails are usually sent with the native function. This PHP function sends unauthenticated emails and often, using it, one encounters the problem of unsent emails. To fix it, simply send emails via SMTP with WordPress.

The SMTP protocol, in fact, allows us to send authenticated emails and solve sending problems.

To adopt this system, you can use the SMTP server of your WordPress hosting provider or use a mail provider of your choice.

We will see two methods to send authenticated emails via SMTP:

  1. how to use a simple function (without plugin);
  2. how to do it using a plugin.

Finally, we are going to see the list of the best SMTP plugins for WordPress.

Let's begin.

Wordpress Smtp

WordPress SMTP: the advantages of sending authenticated emails

WordPress allows us to send emails in different cases for example when a new user profile is activated, to recover the password and also in other circumstances.

By default, WordPress sends emails with PHP. However, this system can often cause deliverability problems: emails are not delivered or end up in the spam folder.

This difficulty is due to the fact that when emails are sent with PHP, no authentication system is used. For this reason, many mail messages risk ending up in spam or in some cases not reaching the recipients.

Since WordPress' native configuration for email is limited, we need to use another system that allows us to send authenticated email via SMTP. This will allow us to fix the WordPress not sending email issue.

Let's open a brief parenthesis to understand how authenticated emails work.

How email authentication systems work

SMTP stands for Simple Mail Transfer Protocol and is one of the most used protocols for sending emails. On the other hand we find IMAP: one of the protocols used to receive e-mail.

Unlike the default WordPress feature which uses PHP, the SMTP protocol supports authenticated emails.

Authenticated emails can be sent via SMTP, but how does this authentication work?

There are several email authentication systems, the main ones are:

  • SPF
  • dkim extension
  • DMARC extension.

SPF (Sender Policy Framework) is an authentication method that recognizes mail servers associated with the domain or IP address.

This system allows the ISP to understand if the emails are sent from a reliable sender or not.

DKIM (DomainKeys Identified Mail) is an authentication system based on digital signatures.

DMARC (Domain-Based Message Authentication) works in conjunction with SPF and DKIM methods to verify that emails are authenticated.

How to set up WordPress SMTP without plugins

Now that we have seen the advantages of sending emails with authentication, let's see how to proceed with the configuration.

As we said at the beginning, there are two ways to use the SMTP protocol with WordPress:

  • use a function;
  • use a plugin.

Let's start with the first method and see how to use a function to send emails via SMTP with WordPress.

Benefits of the function

SMTP plugins for WordPress often include other functions than just sending emails. If what interests us is only sending authenticated emails and we don't need other additional operations, using a plugin can be counterproductive.

Using a simple function, the code is only called when sending emails. This means that we can use the feature without affecting the site's performance.

Some plugins slow down WordPress and can have a negative impact on site speed. This problem does not arise if we use a simple function like the one we are going to see in the next chapter.

Using a feature to send authenticated email via SMTP with WordPress

As we said, it is not necessary to use a plugin to send emails via SMTP with WordPress.

We just use this simple function:

remove_action('phpmailer_init', 'swpsmtp_init_smtp');    
add_action( 'phpmailer_init', 'custom_phpmailer_init' );
function custom_phpmailer_init( $phpmailer ) {
    $phpmailer->Host = 'HOSTNAME';
    $phpmailer->Port = 465; //or different  
    $phpmailer->Username = 'USERNAME'; 
    $phpmailer->Password = 'PASSWORD'; 
    $phpmailer->SMTPAuth = true;
    $phpmailer->SMTPSecure = 'ssl';//or tls
    // $phpmailer->XMailer = 'XMAILER'; // Qui possiamo inserire un XMailer diverso

function website_email() {
    $sender_email= '[email protected]';
    return $sender_email;

The function above contains sample data, you'll need to make sure you replace the uppercase and quoted data with the correct SMTP credentials.

  • Host = 'HOSTNAME' – enter the name of the email server.
  • Username = 'USERNAME' – enter username for SMTP authentication.
  • Password = 'PASSWORD' – replace with the password for the SMTP authentication.
  • SMTPSecure = 'ssl' – you can use 'ssl' or 'tls' as protocol.
  • XMailer = 'XMAILER' – you can edit the email header.
  • sender_email= ' [email protected] ' – replace with the email address you want to use for sending.

Where to find the SMTP credentials

With all our plans from shared hosting to LiteSpeed ​​and semi-dedicated plans you can create unlimited email accounts using your own domain (for example [email protected] ).

If you want to use the SMTP server associated with your hosting account, you can find the information you need on the email client settings page. From cPanel, just go to the Email Accounts section.

Cpanel Select Email Account Settings

Then click on Connect Devices to open the configuration page.

Cpanel Email Account Connect Devices

Scrolling down to the "Mail client manual settings" section you will find the data: username, password, outgoing mail server and SMTP port.

Cpanel Smtp Account Email Authentication Details

These are the data you will need to use in the function we saw earlier to configure the SMTP protocol.

How to add the feature

There are several methods to add the function we just saw:

  • put the function in the child theme's functions.php file;
  • use a plugin like Code Snippets;
  • create a site specific plugin.

Let's see how to do it.

Put the function in the functions.php file

One of the simplest methods is to add the function to the functions.php file of the child theme.

We need to make sure that we edit the child theme's functions.php file and not the parent themes. This way when the theme updates, we won't lose the changes and we can continue sending emails via SMTP with WordPress.

Using Code Snippets

If we don't want to modify the functions.php file, we can use a plugin that allows us to add code to the site.

Code Snippets is an example of a plugin that does just that.

We just need to install and activate it.

Install Code Snippet WordPress Plugin

So let's add a new snippet by going to Snippets > Add New.

Code Snippets Add New Snippet

At this point:

  1. Enter a title, for example “Email via SMTP”.
  2. We paste the code in the php functions box and modify the data with the correct ones.
  3. Finally, click on Activate to save the changes.
Code Snippets Add Email Smtp Function

Use a site specific plugin

Another way to add custom code to a WordPress site is to use a site specific plugin.

In practice it is a question of creating a plugin by adding the function we have seen before and then installing and activating it as a normal plugin.

This solution, compared to inserting the code in the functions.phpchild theme file, allows us to have a more flexible system because it is independent of the theme we are using.

Using an SMTP Plugin for WordPress: Pros and Cons

Another way to use the SMTP protocol with WordPress is to use a plugin. We can find several plugins designed for this purpose, we have collected the list of the best WordPress SMTP plugins.

But first of all let's see what are the pros and cons of using one of these plugins.

The main advantage of using a plugin is ease of use. You don't need to have any coding knowledge and you don't need to go and edit any files.

Another advantage of using a plugin is the additional functions. For example, some plugins allow us to have a history of sent emails. It is therefore necessary to evaluate whether the additional functions of the plugin are useful or even indispensable.

In all other cases better not to use a plugin. First of all because if we don't use all the functions, it is superfluous to have a plugin and the very simple function we have seen is enough.

Adding plugins, especially when they have several functions that are not used, can slow down the site. For this reason it is good to check that the chosen plugin does not affect the loading speed.

How to use WP Mail SMTP to send emails via SMTP with WordPress

We have seen that with a simple function we can configure the sending of emails with WordPress via SMTP.

In some cases we may prefer to use a plugin. For this reason, in this part of the guide we are going to see how to configure the sending of emails using one of the best SMTP plugins out there: WP Mail SMTP.

The first thing to do is install and activate the “WP Mail SMTP” plugin in WordPress.

Install Wp Mail Smtp On WordPress

After activating it, we will be redirected directly to the wizard to configure the plugin.

Wp Mail Smtp Wizard Get Started

Configure WP Mail SMTP with the wizard

In the first step we have to choose the SMTP service we want to use.

If we use an email provider like Gmail, we will then have to connect via API. In this case you can refer to the WP Mail SMTP documentation.

If the provider is not in the list, for example if we choose to use the SMTP server of our hosting provider, we just need to select the "Other SMTP" option.

Wp Mail Smtp Wizard Step 1

In the second step, if we have chosen the "Other SMTP" option, there will be the actual configuration. We will have to fill in the information required to connect to the SMTP server manually.

In particular:

  • SMTP host: type the server name.
  • Encryption: we choose the type of encryption, SSL or TLS
  • SMTP Port: insert the correct port number.
Wp Mail Smtp Wizard Step 2

SMTP Username: enter the username.

SMTP Password: type the password.

From Name: we choose the name that will be shown in the sender.

From Email: we choose the email that will be used for sending.

Wp Mail Smtp Wizard Step 2 Authentication Settings

In the third step we can choose the functions we want to use. By default all functions are active, except those reserved for the Pro version of the plugin.

Wp Mail Smtp Wizard Step 3

The fourth step asks us if we want to receive suggestions via email. We can also skip it by clicking on Skip this step.

Wp Mail Smtp Wizard Step 4

If we have purchased the Pro license of WP Mail SMTP we can enter the key in step 5, otherwise we click again on Skip this step.

Wp Mail Smtp Wizard Step 5

The final step will be to verify and let us know if the configuration is correct.

Change WP Mail SMTP settings

If we want to change the settings of this SMTP plugin after completing the wizard, just go to WP Mail SMTP > Settings.

Wp Mail Smtp Email Test

From here we will be able to modify the data that we entered during the configuration.

Or we can change the email sending service to use, choosing one of those present.

Wp Mail Smtp Choice Mailer

Note that the PHP (default) option is also present, which is the native WordPress function.

Problems configuring WP Mail SMTP

In case of errors during the configuration, we will see a screen like this and we will be able to start the troubleshooting procedure.

Wp Mail Smtp Wizard Step 6

By clicking on "Start Troubleshooting" we will be redirected to the test page and will be able to access the error log to understand what problem is preventing the sending of the test email.

Wp Mail Smtp Email Test Error

We can also open the Debug Events section, like this:

Wp Mail Smtp Debug Events

Here we will find the list of errors that occurred while trying to send the emails.

Wp Mail Smtp Errors Log

Test sending emails

To carry out a new email sending test with WP Mail SMTP, just click on WP Mail SMTP > Email Test.

Wp Mail Smtp Email Test

Make sure that the recipient's email is correct and click on the "Send Email" button.

Wp Mail Smtp Send A Test Email

The best SMTP plugins for WordPress

The plugin we just saw, WP Mail SMTP, is just one possible system.

Now let's see the features of the best plugins that allow us to send emails via SMTP with a WordPress site.

In this list we have collected the most complete plugins: these are extensions that are also available in a free version and are all compatible with the main email services.

Let's see in detail:

  • WP MailSMTP;
  • EasyWPSMTP;
  • SMTP Post;
  • FluentSMTP.

We will then see other specific plugins for certain email providers.

WP Mail SMTP (free and premium)

WPForms' WP Mail SMTP is undoubtedly the most used WordPress SMTP email plugin. There are currently over 3 million WordPress installations using it.

Wordpress Plugin Wp Mail Smtp

The extension is compatible with WordPress version 6.0.3 and is kept up-to-date by the developers.

You can configure the SMTP server by entering the necessary credentials or you can directly use the APIs to use services such as Gmail, SendLayer, Sendinblue, Amazon SES and others.

WP Mail SMTP is a free WordPress SMTP plugin. In addition, if you need to use other functions, you can evaluate the purchase of the Pro version.

With WP Mail SMTP Pro you have several additional functions, let's see some of the most interesting ones.

  • Email log: the plugin allows you to store the history of sent emails.
  • Resending emails: You can use the email history to resend or resend emails.
  • Email opening rate: you can access statistics that let you know how many times emails have been opened.
  • Attachment storage: You can save attachments so you can send them faster later.
  • Export of email logs: you can download the email history in different formats such as csv and Excel.


In addition to the free version of the plugin, you can purchase one of the premium licenses.

  • WP Mail SMTP Pro: It is a single site license with the features we mentioned before and some additional ones. The cost is $49.00 per year.
  • WP Mail SMTP Elite: other advanced features are added to the pro functions, such as the ability to test sending emails. Cost $99.00 per year.
  • WP Mail SMTP Developer: ideal for multiple sites, the license is valid for up to 20 sites. The price is $199.00 per year.
  • WP Mail SMTP Agency: Ideal for multiple sites, up to 100 websites. The annual license costs $399.00.

Easy WP SMTP (free)

If you are looking for a free plugin to configure SMTP with WordPress, Easy WP SMTP could be the one for you.

Wordpress Plugin Easy Wp Smtp

Among the functions included in this plugin we mention:

  • the ability to send emails with Gmail, Hotmail and Yahoo (just have an account);
  • send test emails to understand if the configuration used is correct;
  • an option that allows us to activate debugging and make sure that emails are sent correctly.


Easy WP SMTP is a free SMTP plugin.

Post SMTP Mailer/Email Log (free and premium)

Post SMTP Mailer/Email Log developed by Post SMTP is a plugin available in free and premium version.

Wordpress Plugin Post Smtp Mailer

Among the basic functions, available in the free version of this plugin, we find:

  • a wizard that accompanies us during the configuration of the plugin;
  • a test system to verify that the sending of emails is correct;
  • the ability to access the email history and resend emails if there have been problems;
  • API support for major services including: Gmail, Mailgun, Mandrill, SendGrid and Sendiblue;
  • the ability to install a Chrome extension to display notifications if emails are not sent correctly.


Pro version extensions allow us to use other services such as Amazon SES, Office 365, Better Email Logger, Twilio and Mail Control.

Post SMTP Mailer offers several annual subscription plans: Basic, Basic Plus and Ultimate.

  • Basic, starting at $34.99, includes a single site license and the pro extensions mentioned above.
  • Basic Plus, starting at $69.99 also includes setup as well as a single site license, plus one year of support and an additional year of guaranteed updates.
  • Ultimate, starting at $104.99, is a license valid for 30 sites and includes the additional features of the other plans.

FluentSMTP (free)

FluentSMTP by FluentSMTP & WPManageNinja Team is one of the most useful WordPress SMTP plugins.

Wordpress Plugin Fluentsmtp

The plugin supports API connection with major email services including Gmail, Outlook, Amazon SES, Google Workspace and more. We are talking about a free plugin that includes several features including:

  • email logs;
  • a function to resend emails;
  • the debug function to solve sending problems;
  • a reporting system to keep track of sent emails;
  • Compatibility with several form builder plugins including Elementor Forms and Contact Form 7.


FluentSMTP is a completely free SMTP plugin.

Other SMTP plugins for WordPress

We have just seen the most used plugins to send authenticated emails via SMTP. Then there are other specific plugins for email providers, let's see some of them.

If you use only one provider, it can be convenient to use a specific plugin instead of a generic one.

Gmail smtp

It is the specific SMTP plugin for Gmail.

Wordpress Plugin Gmail Smtp

To use it, all you need is a Gmail account, the plugin allows us to connect via API using OAuth 2.0 authentication.

Newsletter, SMTP, Email marketing and Subscribe forms by Sendinblue

Sendinblue has an official plugin that also allows us to send emails via SMTP with WordPress.

Wordpress Plugin Newsletter Smtp Sendinblue

In this case it is not only an SMTP plugin, but there are also other functions such as managing contact lists and sending email campaigns.

With this plugin we can connect to the Sendinblue account via API and send emails via SMTP.

HubSpot – CRM, Email Marketing, Live Chat, Forms & Analytics

HubSpot has an official and free plugin that allows us to manage email campaigns and contact list directly from WordPress.

Wordpress Plugin Hubspot Crm

In this case we are not talking about a real SMTP plugin. Using this extension, however, we can also configure the SMTP protocol to send emails and therefore not having to use the default WordPress system.


Sending emails via SMTP with WordPress allows us to solve sending problems. If the emails you send often end up in spam or fail to arrive in your inbox, you can almost certainly solve the problem this way.

We have seen how to use SMTP with WordPress with a simple function. Alternatively, you can also use a plugin, for instance one of those in our list.

In either case, you can use your hosting provider's SMTP server or a third-party service.

Were you able to configure WordPress to send authenticated emails? Let us know in the comments which method you used.

author image

Ivan Messina

Founder of SupportHost. With over 10 years of experience in web hosting, he works every day to improve the service and pays attention to each and every customer.

Related posts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.