Stand with Ukraine 🇺🇦 Donate to support

WordPress SMTP Settings

On November 23, 2019
5min read
Diana Lepilkina Content Specialist @Mailtrap

If you have a website running on WordPress and need to send newsletters or email notifications, then you have to perform additional setup actions. The native WordPress functionality for email sending uses the PHP mail() function, which is not the best option. First, its capabilities are pretty limited so that you can’t easily build HTML templates, embed images, or add attachments. Second, PHP mail() is poor with proper email headers. And this is just one of the reasons why such emails frequently land in spam folders. The latter increases the risk of lowering your domain reputation with mass emails. 

Some WordPress hosts, like One, Warpgate, or Tap, have an SMTP server already pre-configured for each website – but this is more a rare exception than a trend among hosting providers. In most cases, additional steps will need to be made to ensure maximum deliverability for your emails.

To improve email deliverability, it is recommended to send all WordPress emails via an SMTP server. And here you have two reliable options:

  1. Setup SMTP programmatically.
  2. Integrate it with the help of a WordPress plugin. 

In this article, we will inspect both options so you can choose the one suitable for you. 

How to configure SMTP settings in WordPress programmatically

This is a tech-savvy method. If you are ready to deal with the email development using PHPMailer and don’t want to depend on WordPress plugins, this option is for you. The setup is quite easy. Go to your functions.php file and configure the WordPress SMTP settings with the following code: 

add_action( 'phpmailer_init', 'setup_phpmailer_init' );
function setup_phpmailer_init( $phpmailer ) {
    $phpmailer->Host = 'HOSTNAME'; // for example,
    $phpmailer->Port = 587; // set the appropriate port: 465, 2525, etc.
    $phpmailer->Username = 'YOURUSERNAME'; // your SMTP username
    $phpmailer->Password = 'YOURPASSWORD'; // your SMTP password
    $phpmailer->SMTPAuth = true;
    $phpmailer->SMTPSecure = 'tls'; // preferable but optional

That’s it! Save the file: now you can manage your emails with PHPMailer and your SMTP server. 

Note: WordPress was updated to the 5.5 version on Aug 11, 2020, that affected the PHPMailer library (support updated from 5.2.27 to 6.1.6.). This update might have caused errors with the previous integrations.

How to send emails via an SMTP server with a WordPress plugin

An even more popular option for integrating your SMTP server with your WordPress site is installing the appropriate plugin. On the “Plugins” page in WordPress, you will find around 400 results for the “SMTP” search query. How do you choose the right one? Check the following details:

  • number of active installations 
  • compatibility/tests with the latest WordPress version
  • reviews

As a result, we have chosen four plugins that have high popularity, work properly according to users’ reviews, and are regularly updated and tested. 

WP Mail SMTP by WPForms

WP Mail SMTP is the most used plugin with over one million active installations. Its free version allows you to integrate your preferred SMTP server or choose one of the built-in email sending providers (Sendinblue, Mailgun, SendGrid, and Gmail). The Pro version adds support for Amazon SES, Outlook, and Office 365.  The more advanced plans allow you to set up DNS verifications as well as test and verify email delivery

In general, the plugin setup is super easy and no coding skills are required. 

WP Mail SMTP Settings
Source: WP Mail SMTP

So you just go to the Settings page, choose a built-in mailer or “Other SMTP” if you use another provider. If you are going to send emails with one of the integrated providers, you will need to login to your account and configure the minimum settings. When using an alternative server, you will have to enter:

  • your SMTP hostname
  • SMTP port
  • encryption method 
  • username and password to authenticate
Other SMTP settings in WP Mail SMTP
Source: WP Mail SMTP

Note that in this case, your password will be stored in the website database in plain text. This why for extra security it is recommended to set up the password in your wp-config.php file by adding these two lines of code:

define( 'WPMS_ON', true );
define( 'WPMS_SMTP_PASS', 'your_password' );

Once the configuration file is successfully updated, the password field in the setting will be disabled. If you are new to WordPress, you might want to check their instructions on editing wp-config.php.


Easy WP SMTP is a similar and simple plugin for WordPress SMTP setup. It also uses the PHPMailer library. Its capabilities include:

  • integration with Gmail, Yahoo, and Hotmail SMTP
  • debugging and logging
  • export and import of SMTP settings 
Easy WP SMTP Settings
Source: Easy WP SMTP

Like in a previous example, you will need to specify hostname, port, encryption and authentication details, as well as set up the “From” name and address. The debugging option lets you send a test message to any email address. 

Post SMTP Mailer/Email Log

Post SMTP mailer utilizes Zend_Mail and in addition to the SMTP server setup provides the following capabilities:

  • logging and resending all emails 
  • custom email headers along with Cc and Bcc 
  • OAuth 2.0 authentication for Gmail, Hotmail, and Yahoo
  • API support for Gmail, Mailgun, Mandrill, and Sendgrid
  • email failure notifications for Chrome 
Post SMTP Mailer setup - Mailtrap
Source: Post SMTP Mailer

Email Subscribers & Newsletters

This plugin is not a pure SMTP integration solution. It provides advanced functionality for sending newsletters and managing subscribers from your WordPress site or blog. The main capabilities include:

  • HTML editor 
  • broadcast sending
  • email scheduling
  • subscription box
  • sent emails report
  • support for localization and internationalization
  • user access control 
Email Subscribers & Newsletters, delivery report
Source: Email Subscribers & Newsletters

Custom SMTP integration is available in paid subscription plans, which start at $6.50 monthly. 

CBX Email SMTP & Logger for WordPress

CBX Email SMTP & Logger for WordPress plugin helps to send emails using SMTP and logs them to keep the record. You can use multiple SMTP services to test email sending, you can also utilize features such as resenting, auto-deleting emails, and previews.

Source: CBX Email SMTP & Logger for WordPress

The core plugin is free with all the major features.

How to integrate WordPress with your email sending provider?

As we have demonstrated above, you can set up an SMTP server manually or with one of the SMTP plugins that are compatible with Namecheap, Hosting Forest, Kinsta, and many other popular WordPress hosts.

In addition, the most popular email sending providers have their own official plugins:

Note: We listed only those plugins, which have been updated in the last year

How to Test Emails via SMTP with Mailtrap Email Sandbox

No matter the method you choose for email-sending functionality in WordPress via SMTP, it should be properly tested before going live. This is exactly what Mailtrap Email Sandbox was designed for, to help developers test their staging emails in a safe environment without the risk of spamming anyone. 

Once you have created an account and verified it, go to the “Inboxes” tab from the drop-down “Integrations” menu, select “WordPress”, copy the generated code with your credentials, and paste it into your WordPress settings file or appropriate plugin tab.

After the quick setup process, you can easily start checking email headers, preview how emails appear across different devices, validate HTML/CSS, and get detailed spam reports. 

Article by Diana Lepilkina Content Specialist @Mailtrap


3 replies

Jared Mitchell

WP 5.5 has upgraded.

The PHPMailer library just got a major update, going from version 5.2.27 to 6.1.6.

This broke the mailtrap plugin due to class reference

public function mailer_setup(PHPMailer $phpmailer)

Needs to be update to

public function mailer_setup(PHPMailerPHPMailerPHPMailer $phpmailer)

While I found this in a plugin it also applies to the above function reference


you are a life saver. thank you

Diana Lepilkina

Hello Jared, thanks for reporting this!
We have updated this post accordingly. However, we don’t have a Mailtrap plugin for WordPress — we know there is a couple of plugins on their marketplace but they are not official.

Comments are closed.