Setting Up SendGrid With WordPress

 In Plugins, WordPress

A common issue I see when working on WordPress sites is e-mail delivery. Many customers choose to work with shared hosting, which makes a lot of sense financially, but often comes with other issues. One of these common issues is having e-mails blocked because the server your website lives on has been blacklisted by various e-mail services. This occurs a lot on shared hosting plans because they are so cheap that spammers use them to quickly setup cheap sites. And because your website is hosted on the same server, your e-mails come from the same IP and thus will be subject to the same filtering as the spammers.

So what can you do? Aside from moving off your shared hosting to a VPS or Dedicated Server where you’ll have a dedicated IP address, one option is to use a 3rd party system to handle e-mails. Typically these services offer a plugin that overrides WordPress e-mail functionality and passes all e-mails to their own system, from where they are sent. Because these systems are all reputable, their servers will not be black-listed by any other e-mail systems and thus your e-mails should be delivered without issue.

In this post, we’ll look at my favorite 3rd party e-mail system, SendGrid. I’ll show you how easy it is to setup WordPress with SendGrid so that you never have to worry about you or your customers missing another e-mail.

Setting Up WordPress With SendGrid

To get started, you’ll need to create a free account with SendGrid here. As of this writing SendGrid offers a free tier of service, though that is subject to change in the future. Even at a nominal cost, having peace of mind for you and your customer e-mails is well worth it.

Once you have an account, login and navigate to Settings -> API Keys. SendGrid lets you have multiple API Keys, which is great for web developers like myself who manage multiple sites. I can often show my clients the benefits of using WordPress with SendGrid before they signup themselves. Generate an API Key for your site and give it a meaningful name. This name is only for your records, and I usually just use the domain name. SendGrid will ask for the list of permissions to grant to the key. For our purposes, we only need to grant full access for Mail Send. Without this, the WordPress plugin will not let you use the API Key. The screen shot below shows what you need to configure:

WordPress With SendGrid API Key

How to setup your SendGrid API Key for WordPress.

With the API Key in hand, you can install the WordPress plugin for SendGrid. This is available in the standard plugin repository and can be found by simply searching for sendgrid. Alternatively, you can download it here and install it manually via upload. Once installed and activated, there is a single settings screen to configure:

SendGrid WordPress setup screen.

You’ll of course need the API Key you generated earlier, and you’ll also want to make sure Send Mail With is set to API (more on this below). Below that it will ask for the e-mail address and name to use for sending e-mails, as well whether to use plan text or HTML (more than likely you want to use HTML, especially if you’re using WooCommerce). The other fields are specific to your SendGrid account and can be ignored and left blank. Once you fill everything out, make sure you send a test e-mail to yourself and maybe a couple other addresses.

And that’s it! From now on all e-mail sent by any plugin or your theme will be sent using SendGrid’s infrastructure. Being a global leader in e-mail as a service, you can rest easy knowing your e-mails will be delivered on time to every recipient.

SMTP vs. API

One thing to understand with 3rd party e-mail systems and WordPress is that there are two ways to send e-mails:

  • SMTP: The Simple Mail Transport Protocol, which is normally used to send e-mails.
  • API: A simple HTTP call, similar to what your web browser used to load this page.

The SMTP method usually does not work with WordPress servers because SMTP uses a variety of ports, most of which are locked down by hosting providers. API, on the other hand, uses the normal HTTP protocol on standard ports (80 for non-secure, 443 for secure). Because most modern websites rely heavily on 3rd party data that is communicated over HTTP on these standard ports, the ports are already open and there is no concern with hosting providers blocking them. And remember, the HTTP is only between your WordPress server and the 3rd party service (in this case SendGrid). The HTTP call contains everything needed to send e-mail. The 3rd party system will then send the e-mail to the recipient(s) using normal protocols like SMTP.

Recent Posts
Zillow WordPress PluginWordPress Menu Button Cover
Verified by ExactMetrics