Configuring the 'WP Mail SMTP' plugin with Gmail


This article explains how to use the WP Mail SMTP plugin to send email from your WordPress site, using your Google email address.

If you do not want to use a Gmail address to send from your WordPress site, view the following article instead.

Configuring the WP Mail SMTP plugin

  1. In the WordPress dashboard, click 'Plugins > Add New' in the left pane.
  2. Search for wp-mail-smtp. It can also be found here.
    wp mail smtp plugin
  3. Click the Install button, then Activate. 
  4. After it's installed and activated, navigate to the 'Plugins' page in your WordPress dashboard.
    wp mail smtp plugin
  5. Click the Settings link under the plugin.
    WP Mail SMTP.png
  6. Fill in the following fields:
    • From Email - Enter the email you wish to send FROM
    • Force From Email - Check this box
    • From Name - Enter a name you'd like to appear as being sent FROM
    • Force From Name - Check this if you wish to force the FROM name
    • Return Path - Check this box
    wp mail smtp
  7. Under the Mailer section select Gmail.
    wp mail smtp
  8. Scroll down to the Gmail section.
    • Client ID - This is a string of letter and numbers you will create in your Google account.
    • Client Secret - This is a string of letter and numbers you will create in your Google account.
    • Authorized redirect URI - You will input this into your Google account.
  9. Click the Save Settings button.

You must now configure your settings within your Google account.

Allowing GMAIL to send from your mail application

You now must allow Google to send email from your WordPress site. You can do this by enabling OAuth2 authentication in your Google account.

Adding code to hide your credentials

The instructions above add your Google credentials to the WordPress dashboard. To further secure your credentials, the plugin recommends you add code to your wp-config.php file instead. View the following page for further details.

Adding the constants to your wp-config.php file

  1. Log into your server via FTP or SSH.
  2. Use one of the following articles to edit your wp-config.php file.
  3. Scroll down in this file to the following line:

    /* That's all, stop editing! Happy blogging. */

  4. Add the following lines just above this line.
    define( 'WPMS_ON', true );
    define( 'WPMS_GMAIL_CLIENT_ID', '********************');
    define( 'WPMS_GMAIL_CLIENT_SECRET', '**********************');
    define( 'WPMS_MAILER', 'gmail' );
  5. The only parts you need to change are WPMS_GMAIL_CLIENT_ID and WPMS_GMAIL_CLIENT_SECRET.
  6. Save the file.
    wp mail smtp password
  7. If you view the plugin page now, you'll see your credentials are not accessible.

See also

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?