Use WP Mail SMTP to Send Email with Sendgrid
This popular plugin is easy to configure for use with SendGrid.
Contributors: Alex Fornuto.
Discuss in our Forum Discuss in SlackSendGrid is a popular email service, but its WordPress plugin hasn't been updated in several years or tested with the latest 3 (as of this writing) major releases of WordPress.
This guide will cover how to install and configure WP Mail SMTP to send emails from your WordPress site using Sendgrid
Note
WP Mail SMTP is not the only plugin available to integrate WordPress with Sendgrid, nor is it officially endorsed by Pantheon as the preferred method.
Before You Begin
This guide assumes a pre-existing configuration of:
- An configured WordPress site. See our Quick Start guide if you need to set up a new WordPress site on Pantheon.
- A familiarity with the WebOps workflow, as we will be moving code and content between environments.
- A SendGrid account and API key. Follow the steps in Create a SendGrid Account to create and authenticate an account.
- If your site has access to Multidev, we suggest creating a new Multidev environment to work in. If so, substitute the Multidev name for
devin the guide below, unless otherwise noted.
Install the WP Mail SMTP Plugin
There are several ways to install and manage WordPress plugins on Pantheon. This guide will cover installation from the WordPress Admin Dashboard, and from the command line using Terminus and WP-CLI.
Each method requires first setting your working environment (Dev or a Multidev environment) to SFTP mode.
Install from the WordPress Admin Dashboard
From the Site Dashboard, navigate to the Dev (or Multidev) environment, and click on the Site Admin button. Log in to your WordPress Admin Dashboard.
Select Plugins, then Add New
In the search box, type "wp mail smtp". Results will update automatically. Locate WP Mail SMTP by WPForms and click Install Now:
Once installed, the same button will change to say Activate. Click it again.
WP Mail SMTP is now installed! You can now continue to Configure WP Mail SMTP for SendGrid.
Install with Terminus
Exports
When using Terminus, we suggest defining the variables $site and $env in your terminal session to match your site name and the Dev (or Multidev) environment:
export site=yoursitename
export env=dev #Or a multidev nameConfirm that the environment is in SFTP mode:
terminus connection:set $site.$env sftp [notice] The connection mode is already set to sftp.Invoke WP-CLI over Terminus to install and activate WP Mail SMTP:
terminus wp $site.$env -- plugin install --activate wp-mail-smtp Warning: Permanently added '[appserver.sendgridsmtp.0e1f236a-....drush.in]:2222,[35.223.224.107]:2222' (RSA) to the list of known hosts. Installing WP Mail SMTP by WPForms (2.5.1) Warning: Failed to create directory '/.wp-cli/cache/': mkdir(): Read-only file system. Downloading installation package from https://downloads.wordpress.org/plugin/wp-mail-smtp.2.5.1.zip... Unpacking the package... Installing the plugin... Plugin installed successfully. Activating 'wp-mail-smtp'... Plugin 'wp-mail-smtp' activated. Success: Installed 1 of 1 plugins. [notice] Command: anita-wordpress.sendgridsmtp -- wp plugin install wp-mail-smtp [Exit: 0]
Configure WP Mail SMTP for SendGrid
From the WordPress Admin Dashboard's Plugins Page, locate WP Mail SMTP and click on Settings.
Under the General tab, in the Mail section, provide values for "From Email" and "From Name". In the Mailer subsection, select SendGrid:
In the next section, paste in your API key, then select Save Settings.
To confirm your settings are correct, select the Email Test tab and send a test email to yourself. Be sure to check your spam folder for the test message.
Congratulations, you've configured WP Mail SMTP for SendGrid!