WordPress.org

Plugin Directory

SendGrid

Send emails and upload contacts through SendGrid from your WordPress installation using SMTP or API integration.

Requirements:

  1. PHP version >= 5.3.0
  2. To send emails through SMTP you need to also install the 'Swift Mailer' plugin. ( https://wordpress.org/plugins/swift-mailer/ )
  3. If wp_mail() function has been declared by another plugin that you have installed, you won't be able to use the SendGrid plugin

To upload the SendGrid Plugin .ZIP file:

  1. Upload the WordPress SendGrid Plugin to the /wp-contents/plugins/ folder.
  2. Activate the plugin from the "Plugins" menu in WordPress.
  3. Create a SendGrid account at http://sendgrid.com/partner/wordpress
  4. Navigate to "Settings" -> "SendGrid Settings" and enter your SendGrid credentials

To auto install the SendGrid Plugin from the WordPress admin:

  1. Navigate to "Plugins" -> "Add New"
  2. Search for "SendGrid Plugin" and click "Install Now" for the "SendGrid Plugin" listing
  3. Activate the plugin from the "Plugins" menu in WordPress, or from the plugin installation screen.
  4. Create a SendGrid account at http://sendgrid.com/partner/wordpress
  5. Navigate to "Settings" -> "SendGrid Settings" and enter your SendGrid credentials

Global Settings

SendGrid settings can optionally be defined as global variables (wp-config.php):

  1. Set credentials (You can use credentials or API key. If using credentials, both need to be set in order to get credentials from variables and not from the database. If using API key you need to make sure you set the Mail Send permissions to FULL ACCESS, Stats to READ ACCESS and Template Engine to READ or FULL ACCESS when you created the api key on SendGrid side, so you can send emails and see statistics on wordpress):

    • Auth method ('apikey' or 'credentials'): define('SENDGRID_AUTH_METHOD', 'apikey');
    • Username: define('SENDGRID_USERNAME', 'sendgrid_username');
    • Password: define('SENDGRID_PASSWORD', 'sendgrid_password');
    • API key: define('SENDGRID_API_KEY', 'sendgrid_api_key');
  2. Set email related settings:

    • Send method ('api' or 'smtp'): define('SENDGRID_SEND_METHOD', 'api');
    • From name: define('SENDGRID_FROM_NAME', 'Example Name');
    • From email: define('SENDGRID_FROM_EMAIL', 'from_email@example.com');
    • Reply to email: define('SENDGRID_REPLY_TO', 'reply_to@example.com');
    • Categories: define('SENDGRID_CATEGORIES', 'category_1,category_2');
    • Template: define('SENDGRID_TEMPLATE', 'templateID');
    • Content-type: define('SENDGRID_CONTENT_TYPE', 'html');
    • Unsubscribe Group: define('SENDGRID_UNSUBSCRIBE_GROUP', 'unsubscribeGroupId');
  3. Set widget related settings:

    • Marketing Campaigns API key: define('SENDGRID_MC_API_KEY', 'sendgrid_mc_api_key');
    • Use the same authentication as for sending emails ('true' or 'false'): define('SENDGRID_MC_OPT_USE_TRANSACTIONAL', 'false');
    • The contact list ID: define('SENDGRID_MC_LIST_ID', 'listID');
    • Display the first and last name fields ('true' or 'false'): define('SENDGRID_MC_OPT_INCL_FNAME_LNAME', 'true');
    • First and last name fields are required ('true' or 'false'): define('SENDGRID_MC_OPT_REQ_FNAME_LNAME', 'true');
    • Signup confirmation email subject: define('SENDGRID_MC_SIGNUP_EMAIL_SUBJECT', 'Confirm subscription');
    • Signup confirmation email content: define('SENDGRID_MC_SIGNUP_EMAIL_CONTENT', '<a href="%confirmation_link%">click here</a>');
    • Signup confirmation page ID: define('SENDGRID_MC_SIGNUP_CONFIRMATION_PAGE', 'page_id');

Filters

Use HTML content type for a single email:

add_filter('wp_mail_content_type', 'set_html_content_type');

// Send the email 

remove_filter('wp_mail_content_type', 'set_html_content_type');

Change the email contents for all emails before they are sent:

function change_content( $message, $content_type ) {   
    if ( 'text/plain' == $content_type ) {
      $message = $message . ' will be sent as text ' ;
    } else {
      $message = $message . ' will be sent as text and HTML ';
    }

    return $message;
}

add_filter( 'sendgrid_override_template', 'change_content' );

Changing the text content of all emails before they are sent:

function change_sendgrid_text_email( $message ) {
    return $message . ' changed by way of text filter ';
}

add_filter( 'sendgrid_mail_text', 'change_sendgrid_text_email' );

Changing the HTML content of all emails before they are sent:

function change_sendgrid_html_email( $message ) {
    return $message . ' changed by way of html filter ';
}

add_filter( 'sendgrid_mail_html', 'change_sendgrid_html_email' );

Note that all HTML emails sent through our plugin also contain the HTML body in the text part and that content will pass through the "sendgrid_mail_text" filter as well.

Requires: 4.2 or higher
Compatible up to: 4.5.3
Last Updated: 2 weeks ago
Active Installs: 30,000+

Ratings

4.5 out of 5 stars

Support

6 of 12 support threads in the last two months have been marked resolved.

Got something to say? Need help?

Compatibility

+
=
Not enough data

1 person says it works.
0 people say it's broken.

100,1,1 100,1,1
100,1,1
50,2,1
100,1,1
0,1,0
100,1,1
100,1,1
0,1,0 100,1,1
0,1,0 100,2,2
100,1,1
100,1,1