Requirements: - PHP version >= 5.6 and <= 7.1. Installing this plugin on PHP versions 5.3 and earlier will cause your website to break.
Installation on PHP versions 5.4 and 5.5 will work but it is not recommended. - To send emails through SMTP you need to also install the ‘Swift Mailer’ plugin. ( https://wordpress.org/plugins/swift-mailer/ )
- 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: - Upload the WordPress SendGrid Plugin to the /wp-contents/plugins/ folder.
- Activate the plugin from the “Plugins” menu in WordPress.
- Create a SendGrid account at http://sendgrid.com/partner/wordpress
- Navigate to “Settings” -> “SendGrid Settings” and enter your SendGrid credentials
To auto install the SendGrid Plugin from the WordPress admin: - Navigate to “Plugins” -> “Add New”
- Search for “SendGrid Plugin” and click “Install Now” for the “SendGrid Plugin” listing.
- Activate the plugin from the “Plugins” menu in WordPress, or from the plugin installation screen.
- Create a SendGrid account at http://sendgrid.com/partner/wordpress
- Navigate to “Settings” -> “SendGrid Settings” and enter your SendGrid credentials.
For Multisite: - Navigate to “My Sites” -> “Network Admin” -> “Plugins”
- Click on “Add New”
- Search for “SendGrid Plugin” and click “Install Now” for the “SendGrid Plugin” listing.
- Network Activate the plugin from the “Plugins” menu in WordPress, or from the plugin installation screen.
- Create a SendGrid account at http://sendgrid.com/partner/wordpress
- Navigate to “My Sites” -> “Network Admin” -> “Dashboard”
- Click on the “SendGrid Settings” item in the menu on the left and enter your SendGrid credentials.
Global SettingsSendGrid settings can optionally be defined as global variables (wp-config.php): Set the 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): - API key: define(‘SENDGRID_API_KEY’, ‘sendgrid_api_key’);
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’, ‘[email protected]’);
- Reply to email: define(‘SENDGRID_REPLY_TO’, ‘[email protected]’);
- 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’);
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’, ‘click here’);
- Signup confirmation page ID: define(‘SENDGRID_MC_SIGNUP_CONFIRMATION_PAGE’, ‘page_id’);
Other configuration options: - Set a custom timeout for API requests to SendGrid in seconds: define(‘SENDGRID_REQUEST_TIMEOUT’, 10);
FiltersUse 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. |