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, smtp.mailtrap.io
    $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
    $phpmailer->IsSMTP();

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

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

Any method you choose to set up sending your emails from WordPress via SMTP, you should properly test them before reaching the inboxes of real users. If you use a plugin, you can use its functionality to send test emails to your own inbox. But if you integrate SMTP manually, it is essential to test if email sending actually works. Set Mailtrap as your SMTP server first: it is a fast and easy way to verify email sending functionality, check email headers, and view your messages rendered by a webmail client.

If you have never used Mailtrap before, you can create a free account in just three clicks. Then go to your Mailtrap inbox, copy the necessary settings like hostname, port, your username, and password, and paste them to the WordPress settings file or appropriate plugin tab. Then compose an email and send it. It will be delivered to your Mailtrap inbox right away: 

This way, you can safely test numerous email notifications and different types of messages without flooding your inbox or affecting your domain reputation. 

Once you have verified that your emails look perfect, set your real SMTP server’s credentials and enjoy email sending from your WordPress website.

Article by Diana Lepilkina Content Specialist @Mailtrap

Comments

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

Naseem

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.