What credentials do I need to add on the settings page?

If you do not already have one, simply create a SendGrid account and generate a new API Key.

How can I define a plugin setting to be used for all sites?

To define a plugin setting that you want to use on all of your WordPress sites, simply add it into your wp-config.php file. For example, the following API Key setting would be applicable across each of your WordPress sites:

1
define('SENDGRID_API_KEY', 'your_api_key');

How do I use SendGrid with the WP Better Emails plugin?

If you have the WP Better Emails plugin installed and you want to use the template defined here instead of the SendGrid template, you can add the following code in your functions.php file from your theme:

1
2
3
4
5
6
7
8
9
10
11
12
function use_wpbe_template( $message, $content_type ) {
    global $wp_better_emails;
    if ( 'text/plain' == $content_type ) {
      $message = $wp_better_emails->process_email_text( $message );
    } else {
      $message = $wp_better_emails->process_email_html( $message );
    }

    return $message;
}

add_filter( 'sendgrid_override_template', 'use_wpbe_template', 10, 2 );

Using the default templates from WP Better Emails will cause all emails to be sent as HTML (i.e. content-type of text/html). In order to send emails as plain text (i.e. a content-type of text/plain) you should remove the HTML Template from WP Better Emails settings page. This is can be done by removing the %content% tag from the HTML template.

Why are my emails sent as HTML instead of plain text?

For a detailed explanation of why your emails might be converted to HTML instead of plain text, please see this helpful article in our Classroom.

Will contacts from the widget be uploaded to Marketing Campaigns or Legacy Newsletter?

The contacts will only be uploaded to Marketing Campaigns.

What permissions should my API keys have?

The API Key used to authenticate sending email that you entered on the General tab should have Full Access to Mail Send and Read Access to Stats.

The API Key used when uploading contacts that you entered on the Subscription Widget tab should have Full Access to Marketings Campaigns.

Can I disable the opt-in email?

No. SendGrid’s Email Policy requires that all email addresses sent to by SendGrid customers be confirmed via an opt-in email. In other words, every recipient of an email sent via SendGrid must actively confirm their desire to receive that email by means of an opt-in confirmation.

Can I change the content of the emails before they are sent?

Yes, you can change the content by adding a filter. You need to declare a function that takes the content of the email as an argument and then call add_filter() with the name “sendgrid_mail_text” or “sendgrid_mail_html”, depending on what part of the email you want to change.

If you want to change the text content of all emails before they are delivered, add the following to the functions.php file of your WordPress installation.

1
2
3
4
5
function change_sendgrid_text_email( $message ) {
    return $message . ' changed by way of text filter ';
}

add_filter( 'sendgrid_mail_text', 'change_sendgrid_text_email' );

If you want to change the HTML content of all emails before they are delivered, simply add the following to the functions.php file of your WordPress installation.

1
2
3
4
5
function change_sendgrid_html_email( $message ) {
    return $message . ' changed by way of html filter ';
}

add_filter( 'sendgrid_mail_html', 'change_sendgrid_html_email' );

Please note: what is changed in your emails depends on the content-type that you have set in the settings page or overwritten in a filter.

For “text/plain,” only the text part is overwritten by the filter. For “text/html,” both the text and the HTML filters are called.

The code snippets above are usually added in the functions.php file of your theme.

Can the SendGrid Plugin be used on a multisite network?

Yes. This plugin has basic multisite network support.

To use the SendGrid plugin on your multisite network, navigate to your WordPress dashboard and click My Sites, select Network Admin, and click on Plugins. Under the SendGrid WordPress plugin, click Network Enable.

The settings for all sites in the network can only be configured by the network admin in the Network Admin dashboard.

Please note: you may not specify different plugin settings for each site in your network. The same settings will be used across your entire multisite network.

Related Content