Code Monkey home page Code Monkey logo

wordpress's Introduction

SendGrid

  • Contributors: SendGrid
  • Donate link: http://sendgrid.com/
  • Tags: email, email reliability, email templates, sendgrid, smtp, transactional email, wp_mail,email infrastructure, email marketing, marketing email, deliverability, email deliverability, email delivery, email server, mail server, email integration, cloud email
  • Requires at least: 4.6
  • Tested up to: 4.9
  • Stable tag: 1.11.8
  • License: GPLv2 or later
  • License URI: http://www.gnu.org/licenses/gpl-2.0.html

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

Description

What is the SendGrid WordPress Plugin?

SendGrid’s cloud-based email infrastructure relieves businesses of the cost and complexity of maintaining custom email systems. SendGrid provides reliable deliverability, scalability, and real-time analytics along with flexible APIs that make custom integration with your application a breeze.

SendGrid’s WordPress plugin replaces WordPress’s default wp_mail() function by using either an SMTP or API integration with SendGrid to send outgoing email from your WordPress installation. It also allows you to upload contacts directly to your SendGrid Marketing Campaigns account via a subscription widget.

By using the SendGrid plugin, you will be able to take advantage of improved deliverability and an expanded feature set, including tracking and analytics, to enhance user engagement on your WordPress installation. SendGrid also provides world class customer support, should you run into any issues.

For more details, consult our official documentation

For assistance you can contact SendGrid Support from the SendGrid Support Portal. Click Login & Contact Support, and then Contact Support to see your support contact options. Paying SendGrid customers have the option to contact support via phone, chat, or by submitting a ticket using our web form. All SendGrid customers have the option to submit a ticket using our web form.

Agency Program

Are you sending emails on behalf of your clients? SendGrid's Agency Program offers exclusive pricing and support for agencies looking to improve their email program.

Want to learn more? Visit the SendGrid Agency Page

The Subscription Widget

SendGrid’s WordPress Subscription Widget makes it easy for people visiting your WordPress site to subscribe to your marketing emails, such as any newsletters, announcements, or promotional offers you may send. Upon signup, they’ll automatically receive an opt-in email allowing them to confirm their desire to begin receiving your emails. This confirmation constitutes “double opt-in,” a deliverability best practice.

For more details, consult the official documentation for the Subscription Widget

Multisite

If you are using the SendGrid plugin in a Multisite environment, you need to Network Activate it. You can then access the settings page on the network dashboard and the configure settings will be used for all sites.

You can enable access for SendGrid settings to each subsite in the Multisite Settings tab. If the checkbox is unchecked then that site will not see the SendGrid settings page and it will use the settings set on the network. Warning! When you activate SendGrid management for a subsite, that site will not be able to send emails until the admin updates the SendGrid settings on that subsite.

If you already had the plugin installed in a Multisite environment and you update to versions after 1.9.0 you may need to reconfigure your plugin.

Installation

Requirements:

  1. 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.
  2. To send emails through SMTP you need to install also the 'Swift Mailer' plugin.
  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

For Multisite:

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

Global settings

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

  1. 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');
  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', '[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');
  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');
  4. Other configuration options:

    • Set a custom timeout for API requests to SendGrid in seconds: define('SENDGRID_REQUEST_TIMEOUT', 10);

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.

Frequently asked questions

Does SendGrid have an Agency program?

Yes. If you are sending email on behalf of clients you can find more information on SendGrid's Agency page

Is there any official documentation for this plugin ?

Yes. You can find it here

What PHP versions are supported ?

Plugin versions 1.11.x were tested and confirmed to work on PHP 5.4, 5.5, 5.6, 7.0, 7.1. It DOES NOT work on PHP 5.3 and earlier.

Plugin versions 1.10.x were tested and confirmed to work on PHP 5.3, 5.4, 5.5 and 5.6. It DOES NOT work on PHP 7.0 and later.

What credentials do I need to add on settings page ?

Create a SendGrid account at https://sendgrid.com/partner/wordpress and generate a new API key on https://app.sendgrid.com/settings/api_keys.

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

Add it into your wp-config.php file. Example: define('SENDGRID_API_KEY', 'your_api_key');.

How to use SendGrid with WP Better Emails plugin ?

If you have 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:

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. text/html content-type). In order to send emails as plain text (i.e. text/plain content-type) 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 see this page: https://sendgrid.com/docs/Classroom/Build/Format_Content/plain_text_emails_converted_to_html.html

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 ?

For the API Key used for sending emails (the General tab):

  • Full Access to Mail Send.
  • Read Access to Stats.
  • Read Access to Supressions > Unsubscribe Groups.
  • Read Access to Template Engine. For the API Key used for contact upload (the Subscription Widget tab):
  • Full Access to Marketing Campaigns.

Can I disable the opt-in email?

No. SendGrid’s Email Policy requires all email addressing being sent to by SendGrid customers be confirmed opt-in addresses.

Can I use this plugin with BuddyPress ?

Yes. Our plugin required special integration with BuddyPress and it's regularly tested to ensure it behaves as expected. If you have noticed issues caused by installing this plugin along with BuddyPress, you can add the following line to your wp-config.php to disable it :

define('SENDGRID_DISABLE_BUDDYPRESS', '1');

If you're trying to send plaintext emails using BuddyPress, keep in mind that by default the whitespace content of those emails is normalized.

That means that some newlines might be missing if you expect them to be there.

To disable this functionality, you need to add the following line in your wp-config.php file:

define('SENDGRID_DISABLE_BP_NORMALIZE_WHITESPACE', '1');

Can I use shortcodes to customize the subscription confirmation page ?

Yes. You need to create custom page and select it from the settings page. You can place any of these shortcodes in the body of that page. Here's an example :

Hi [sendgridSubscriptionFirstName] [sendgridSubscriptionLastName],
Your email address : [sendgridSubscriptionEmail] has been successfully added.
You'll hear from us soon!

You need to enable the use of the First Name and Last Name fields from the settings page in order to use the shortcodes for them.

Does this plugin support Multisite?

Yes. This plugin has basic Multisite support. You need to Network Activate this plugin.

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

Since 1.10.5 the Network Admin can delegate the configuration for each subsite to their respective owners. This will allow any subsite to use it's own SendGrid Plugin configuration.

How can I further customize my emails?

When calling the wp_mail() function you can send a SendGrid PHP email object in the headers argument.

Here is an example:

$email = new SendGrid\Email();
$email
    ->setFrom('[email protected]')
    ->setHtml('<strong>Hello World!</strong>')
    ->addCategory('customCategory')
;

wp_mail('[email protected]', 'Subject goes here', 'Message goes here', $email);

You can find more examples here: https://github.com/sendgrid/sendgrid-php/blob/v4.0.2/README.md

My server is slow. Can I increase the timeout for API requests?

Yes. You can define a constant in your wp-config.php file like this:

define('SENDGRID_REQUEST_TIMEOUT', 10);

The value is in seconds, this means that API requests will wait 10 seconds for a reponse from the SendGrid API server until timing out.

Screenshots

  1. Go to Admin Panel, section Plugins and activate the SendGrid plugin. If you want to send emails through SMTP you need to install also the 'Swift Mailer' plugin. screenshot-1
  2. After activation "Settings" link will appear. screenshot-2
  3. Go to settings page and provide your SendGrid API Key. On this page you can set also the default "Name", "Sending Address" and "Reply Address". screenshot-3
  4. If you provide valid credentials, a form which can be used to send test emails will appear. Here you can test the plugin sending some emails. screenshot-4
  5. Header provided in the send test email form. screenshot-5
  6. If you click in the right corner from the top of the page on the "Help" button, a popup window with more information will appear. screenshot-6
  7. Select the time interval for which you want to see SendGrid statistics and charts. screenshot-7
  8. Now you are able to configure port number when using SMTP method. screenshot-8
  9. You can configure categories for which you would like to see your stats. screenshot-9
  10. You can use substitutions for emails using X-SMTPAPI headers. screenshot-10
  11. You can configure the subscription widget. screenshot-11

Changelog

1.11.7

  • Added a configuration parameter of API request timeout in seconds
  • Fixed an issue that made the HTML subscription emails break links

1.11.6

  • Added a feature flag to disable whitespace normalization in BuddyPress plaintext emails
  • Fixed an issue where the from name and email subjects would incorrectly display the ampersand symbol

1.11.5

  • Fixed a potential stored XSS issue on the backend settings form
  • Fixed a potential CSRF issue on the backend settings form

1.11.4

  • Fixed an issue where TO field recipients could not see each other in the email header

1.11.3

  • Fixed an issue where the send test form was displayed when no API key was set
  • Fixed an issue where the subscription test form was not displayed for the default contact list
  • Fixed an issue where the virtual pages for Subscription errors was not displayed
  • Fixed an issue where there was no notification for option update on the Multisite settings page
  • Fixed an issue where there was no notification when an API key was not set on the General tab when there was one on the Subscription Widget tab

1.11.2

  • Relaxed PHP requirement to at least version 5.4.

1.11.1

  • Confirmed compatibility with PHP 7 and 7.1
  • Removed some legacy code that caused warnings in PHP 7
  • Fixed issue where the statistics page would show up in menu even if the API key did not have stats permissions

1.11.0

  • BREAKING CHANGE: DO NOT UPGRADE IF YOU USE PHP <= 5.3. Only PHP 5.4 and later versions are supported.
  • BREAKING CHANGE: Username & Password is no longer supported. Change your settings to use an API Key before updating
  • API Mail Send was changed to use the V3 SendGrid API
  • Emails sent with the V2 Email Object will now be translated to V3
  • BREAKING CHANGE: The date parameter on the V2 object is no longer supported
  • BREAKING CHANGE: When using the V2 object with SMTPAPI Tos, the BCC and CCs will only be applied to the first address

1.10.9

  • Added pagination on multisite settings page
  • Fixed an FAQ link
  • Changed a class method to protected for extensibility (user contribution)
  • Added some CSS classes for subscription widget (user contribution)
  • Added warning when API Key doesn't have statistics permissions
  • The statistics page will not show up in menu or dashboard when API key does not have stats permissions

1.10.8

  • Fixed an XSS vulnerability in the settings forms that would allow other admins to inject scripts

1.10.7

  • Add port 2525 for SMTP
  • Use cache for stats widget on dashboard

1.10.6

  • Fixed logos and fonts on Stats page

1.10.5

  • Added settings page on multisite to give access to self manage SendGrid plugin to each subsite

1.10.4

  • Set transient token for Marketing Campaign in database

1.10.3

  • Add option to configure text version using setText() function from the header
  • Tested up to 4.7

1.10.2

  • Add options to configure subscription widget form (labels, padding)

1.10.1

  • Fixed a javascript error and a PHP warning

1.10.0

  • Added basic Multisite functionality
  • WARNING: Multisite users need to network activate this plugin and reconfigure it.
  • Fixed an issue where other users would see the SendGrid statistics widget on the dashboard.

1.9.5

  • Fixed an issue with the Reply-To field

1.9.4

  • Added Unsubscribe Group option
  • Improved email validation

1.9.3

  • Added BuddyPress integration
  • MC API Key is now saved on focusout
  • Added posibility of using plain text template for subscription confirmation email
  • Added posibility of adding shortcodes to subscription confirmation pages

1.9.2

  • Improved response time on admin dashboard

1.9.1

  • Added filters that allow the change of text or HTML content of all emails before they are sent
  • Fixed an issue with the widget admin notice

1.9.0

  • Added the SendGrid Subscription Widget
  • The settings page now has tabs to separate the configuration of general settings from the widget settings
  • Fixed an issue where a 'gzinflate()' warning was displayed in Query Monitor for each plugin request
  • Fixed an issue where the API Key would be deleted from the db if it was set in wp-config

1.8.2

  • Update SendGrid logos

1.8.1

  • Added possibility to override the email template

1.8.0

  • Added SendGrid\Email() for $header
  • Fix Send Test form not being displayed issue

1.7.6

  • Updated validation for email addresses in the headers field of the send test email form
  • Add ability to have and individual email sent to each recipient by setting x-smtpapi-to in headers

1.7.5

  • Fixed an issue with the reset password email from Wordpress
  • Updated validation for email addresses
  • Fixed an issue where some errors were not displayed on the settings page
  • Add substitutions functionality

1.7.4

  • Fixed some failing requests during API Key checks
  • Fixed an error that appeared on fresh installs regarding invalid port setting

1.7.3

  • Add global config for content-type
  • Validate send_method and port set in config file
  • Be able to define categories for which you would like to see your stats

1.7.2

  • Check your credentials after updating, you might need to reenter your credentials
  • Fixed mcrypt library depencency issue

1.7.1

  • BREAKING CHANGE: Don't make update if you don't have mcrypt php library enabled
  • Fixed a timeout issue from version 1.7.0

1.7.0

  • BREAKING CHANGE : wp_mail() now returns only true/false to mirror the return values of the original wp_mail(). If you have written something custom in your function.php that depends on the old behavior of the wp_mail() you should check your code to make sure it will still work right with boolean as return value instead of array
  • BREAKING CHANGE: Don't make update if you don't have mcrypt php library enabled
  • Added the possibility of setting the api key or username/password empty
  • Added the possibility of selecting the authentication method
  • Removed dependency on cURL, now all API requests are made through Wordpress
  • Sending mail via SMTP now supports API keys
  • Security improvements
  • Refactored old code

1.6.9

  • Add categories in headers, add errror message on statistics page if API key is not having permissions

1.6.8

  • Update api_key validation

1.6.7

  • Ability to use email templates, fix category statistics, display sender test form if we only have sending errors

1.6.6

  • Remove $plugin variable to avoid conflict with other plugins

1.6.5

  • Add configurable port number for SMTP method, Specify full path for sendgrid php library, Fix special characters and new lines issues

1.6.4

  • Add support for toName in API method, Add required Text Domain

1.6.3

  • Update Smtp class name to avoid conflicts

1.6.2

1.6.1

  • Add unique arguments

1.6

  • Fix setTo method in SMTP option, update documentation, add link to SendGrid portal

1.5.4

1.5.3

  • Fix attachments issue

1.5.2

  • Fix urlencoded username issue

1.5.1

  • Fix wp_remote issue

1.5.0

1.4.6

  • Added constants for SendGrid settings

1.4.5

  • Fix changelog order in readme file

1.4.4

  • Fix unicode filename for icon-128x128.png image

1.4.3

  • Update plugin logo, description, screenshots on installation page

1.4.2

  • Added SendGrid Statistics for the categories added in the SendGrid Settings Page

1.4.1

  • Added support to set additional categories

1.4

  • Fix warnings for static method, add notice for php version < 5.3.0, refactor plugin code

1.3.2

  • Fix URL for loading image

1.3.1

1.3

  • Added support for WordPress 3.8, fixed visual issues for WordPress 3.7

1.2.1

  • Fix errors: set_html_content_type error, WP_DEBUG enabled notice, Reply-To header is overwritten by default option

1.2

  • Added statistics for emails sent through WordPress plugin

1.1.3

  • Fix missing argument warning message

1.1.2

  • Fix display for october charts

1.1.1

  • Added default category on sending

1.1

  • Added SendGrid Statistics

1.0

  • Fixed issue: Add error message when PHP-curl extension is not enabled.

Upgrade notice

1.11.7

  • Added a configuration parameter of API request timeout in seconds
  • Fixed an issue that made the HTML subscription emails break links

1.11.6

  • Added a feature flag to disable whitespace normalization in BuddyPress plaintext emails
  • Fixed an issue where the from name and email subjects would incorrectly display the ampersand symbol

1.11.5

  • Fixed a potential stored XSS issue on the backend settings form
  • Fixed a potential CSRF issue on the backend settings form

1.11.4

  • Fixed an issue where TO field recipients could not see each other in the email header

1.11.3

  • Fixed an issue where the send test form was displayed when no API key was set
  • Fixed an issue where the subscription test form was not displayed for the default contact list
  • Fixed an issue where the virtual pages for Subscription errors was not displayed
  • Fixed an issue where there was no notification for option update on the Multisite settings page
  • Fixed an issue where there was no notification when an API key was not set on the General tab when there was one on the Subscription Widget tab

1.11.2

  • Relaxed PHP requirement to at least version 5.4.

1.11.1

  • Confirmed compatibility with PHP 7 and 7.1
  • Removed some legacy code that caused warnings in PHP 7
  • Fixed issue where the statistics page would show up in menu even if the API key did not have stats permissions

1.11.0

  • BREAKING CHANGE: DO NOT UPGRADE IF YOU USE PHP <= 5.3. Only PHP 5.4 and later versions are supported.
  • BREAKING CHANGE: Username & Password is no longer supported. Change your settings to use an API Key before updating
  • API Mail Send was changed to use the V3 SendGrid API
  • Emails sent with the V2 Email Object will now be translated to V3
  • BREAKING CHANGE: The date parameter on the V2 object is no longer supported
  • BREAKING CHANGE: When using the V2 object with SMTPAPI Tos, the BCC and CCs will only be applied to the first address

1.10.9

  • Added pagination on multisite settings page
  • Fixed an FAQ link
  • Changed a class method to protected for extensibility (user contribution)
  • Added some CSS classes for subscription widget (user contribution)
  • Added warning when API Key doesn't have statistics permissions
  • The statistics page will not show up in menu or dashboard when API key does not have stats permissions

1.10.8

  • Fixed an XSS vulnerability in the settings forms that would allow other admins to inject scripts

1.10.7

  • Add port 2525 for SMTP
  • Use cache for stats widget on dashboard

1.10.6

  • Fixed logos and fonts on Stats page

1.10.5

  • Added settings page on multisite to give access to self manage SendGrid plugin to each subsite

1.10.4

  • Set transient token for Marketing Campaign in database

1.10.3

  • Add option to configure text version using setText() function from the header
  • Tested up to 4.7

1.10.2

  • Add options to configure subscription widget form (labels, padding)

1.10.1

  • Fixed a javascript error and a PHP warning

1.10.0

  • Added basic Multisite functionality
  • WARNING: Multisite users need to network activate this plugin and reconfigure it.
  • Fixed an issue where other users would see the SendGrid statistics widget on the dashboard.

1.9.5

  • Fixed an issue with the Reply-To field

1.9.4

  • Added Unsubscribe Group option
  • Improved email validation

1.9.3

  • Added BuddyPress integration
  • MC API Key is now saved on focusout
  • Added posibility of using plain text template for subscription confirmation email
  • Added posibility of adding shortcodes to subscription confirmation pages

1.9.2

  • Improved response time on admin dashboard

1.9.1

  • Added filters that allow the change of text or HTML content of all emails before they are sent
  • Fixed an issue with the widget admin notice

1.9.0

  • Added the SendGrid Subscription Widget
  • The settings page now has tabs to separate the configuration of general settings from the widget settings
  • Fixed an issue where a 'gzinflate()' warning was displayed in Query Monitor for each plugin request
  • Fixed an issue where the API Key would be deleted from the db if it was set in wp-config

1.8.2

  • Update SendGrid logos

1.8.1

  • Added possibility to override the email template

1.8.0

  • Added SendGrid\Email() for $header
  • Fix Send Test form not being displayed issue

1.7.6

  • Updated validation for email addresses in the headers field of the send test email form
  • Add ability to have and individual email sent to each recipient by setting x-smtpapi-to in headers

1.7.5

  • Fixed an issue with the reset password email from Wordpress
  • Updated validation for email addresses
  • Fixed an issue where some errors were not displayed on the settings page
  • Add substitutions functionality

1.7.4

  • Fixed some failing requests during API Key checks.
  • Fixed an error that appeared on fresh installs regarding invalid port setting.

1.7.3

  • Add global config for content-type
  • Validate send_method and port set in config file
  • Be able to define categories for which you would like to see your stats

1.7.2

  • Check your credentials after updating, you might need to reenter your credentials
  • Fixed mcrypt library depencency issue

1.7.1

  • BREAKING CHANGE: Don't make update if you don't have mcrypt php library enabled
  • Fixed a timeout issue from version 1.7.0

1.7.0

  • BREAKING CHANGE : wp_mail() now returns only true/false to mirror the return values of the original wp_mail(). If you have written something custom in your function.php that depends on the old behavior of the wp_mail() you should check your code to make sure it will still work right with boolean as return value instead of array
  • BREAKING CHANGE: Don't make update if you don't have mcrypt php library enabled
  • Added the possibility of setting the api key or username/password empty
  • Added the possibility of selecting the authentication method
  • Removed dependency on cURL, now all API requests are made through Wordpress
  • Sending mail via SMTP now supports API keys
  • Security improvements
  • Refactored old code

1.6.9

  • Add categories in headers, add errror message on statistics page if API key is not having permissions

1.6.8

  • Update api_key validation

1.6.7

  • Ability to use email templates, fix category statistics, display sender test form if we only have sending errors

1.6.6

  • Remove $plugin variable to avoid conflict with other plugins

1.6.5

  • Add configurable port number for SMTP method, Specify full path for sendgrid php library, Fix special characters and new lines issues

1.6.4

  • Add support for toName in API method, Add required Text Domain

1.6.3

  • Update Smtp class name to avoid conflicts

1.6.2

1.6.1

  • Add unique arguments

1.6

  • Fix setTo method in SMTP option, update documentation, add link to SendGrid portal

1.5.4

1.5.3

  • Fix attachments issue

1.5.2

  • Fix urlencoded username issue

1.5.1

  • Fix wp_remote issue

1.5.0

1.4.6

  • Added constants for SendGrid settings

1.4.5

  • Fix changelog order in readme file

1.4.4

  • Fix unicode filename for icon-128x128.png image

1.4.3

  • Update plugin logo, description, screenshots on installation page

1.4.2

  • Added SendGrid Statistics for the categories added in the SendGrid Settings Page

1.4.1

  • Added support to set additional categories

1.4

  • Fix warnings for static method, add notice for php version < 5.3.0, refactor plugin code

1.3

  • Added support for WordPress 3.8, fixed visual issues for WordPress 3.7

1.2

  • Now you can switch between Sendgrid general statistics and Sendgrid WordPress statistics.

1.1

  • SendGrid Statistics can be used by selecting the time interval for which you want to see your statistics.

wordpress's People

Contributors

danielamihalache avatar ghs avatar laur-craciun avatar radusg avatar sendbord avatar stefanysm avatar thomasbachem avatar vladiacobsendgrid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wordpress's Issues

Wont send confirmation email

I just installed the latest plugin version, configured it and wont receive the opt-in email to add the contact to sendgrid when using the subscription widget.

I tested everything using the plugin built-in ui functions and it sends everything perfectly. But when adding the subscription form to a side it won't send the e-mail for confirmation.

Regards,
Fernando

Better error messages (or add logging)

It would be really helpful for developers if error message would contain more information when sending test email. Right now it only states that "Email wasn't sent." and that's really not helpful when trying to figure out the reason for it.

Set site to send via whitelabel domain?

As far as I can tell, it only sends via the main/default whitelabel domain. I'd like to be able to select the whitelabel domain that any given site sends through.

I posted about this on WP.org support forums as well: https://wordpress.org/support/topic/way-to-choose-which-whitelabel-domain-to-send-from/ but there doesn't seem to be any support from SendGrid there.

Please add the ability to determine which whitelabel domain a site should send through. Thanks!

Convert HTML to text when 'text/plain' !== $content_type

When the content type is text/html it will still set the HTML $message as text: setText( $message ):
https://github.com/sendgrid/wordpress/blob/master/lib/sendgrid/sendgrid-wp-mail.php#L285-L288

Maybe you can convert the HTML to plain text? We already wrote a simple plugin for this:
https://github.com/pronamic/wp-pronamic-sendgrid-html2text

Unfortunately this requires a small adjustment in the SendGrid plugin.

There are a few libraries to convert HTML to text:

Is this something you can add, or is there another work around? We use a WordPress form plugin which sends HTML notifications to support system Zendesk. Currently Zendesk doesn't support HTML e-mails so we see the plain text e-mail in Zendesk which contains the complete HTML source.

FEATURE REQUEST: Add ability to enable sandbox mode

In order to maintain dev/prod parity, I keep this plugin enabled in development environments and test all of my forms based on the return value of wp_mail(). It would be helpful, however, if this plugin could give me the option to enable sandbox mode, preferably enabled via a constant. I can set a constant like define('SENDGRID_SANDBOX', true); or some such (this way I can set the value in a .env file and retrieve it per environment), in which case I would expect wp_mail to still return true or false depending on whether the email would successfully send, but similar to WordPress core API, I could retrieve the error via the wp_mail_failed action hook (or any other implementation will do, obviously).

Does this sound feasible?

Email signup fails when user is already a contact

Hi,

We have several lists in sendgrid and our blog newsletter signup adds users to one. When the user is already a contact (as a result of being on one of the other lists) the newsletter signup fails with the general error template/msg: "Something went wrong while trying to send information."

I've debugged this and it looks like the issue is with the static add_recipient method of the class Sendgrid_NLVX in the file class-snedgrid-nlvx.php. In particular this bit:

    if ( ! isset( $recipient_response['persisted_recipients'] ) or ! isset( $recipient_response['persisted_recipients'][0] ) ) {
      return false;
    }

Since the api call returns unmodified_recipients=[0] when the email already exists as a contact, and persisted_recipients=[] this method is failing here.

In this case I guess we also need to fetch the recipient id from sendgrid for the existing contact/email and then we can proceed to add it to the correct list as per usual.

Thanks

Swiftmailer

i have used swift-mailer library custom code to save data and send email.
But currently not working swift-mailer, and it does not throw any error.

swift-mailer stop working after upgrade WordPress.

What should i do, Please give me solution.

Swift Mailer not compatible with latest version of WordPress

Sending through SMTP with SendGrid requires you to install SwiftMailer, however, the latest version hasn’t been tested with the latest 3 major releases of WordPress, but up to 4.5.13 version. What can be done in these cases? Does it work with Wordpress version 4.9.8?

Warning: htmlspecialchars(): charset `UTF-8 ' not supported

if I typed a wrong email for example "ddddd" and submit, it will throw a warning

Warning: htmlspecialchars(): charset `UTF-8 ' not supported, assuming utf-8 in /wp-content/plugins/sendgrid-email-delivery-simplified/lib/class-sendgrid-nlvx-widget.php on line 208

Major XSS and CSRF issues

Hello, this plugin has some serious security issues. There is a lack of nonces and sanitize/escaping.

Please email me at tlovett88 [at] gmail.com so I can disclose.

deprecated filter hook message

Hi, I'm getting an alert in the dashboard that I think originates from line 52 of lib/class-sendgrid-settings.php

// Add SendGrid Help contextual menu in the settings page add_filter( 'contextual_help', array( __CLASS__, 'show_contextual_help' ), 10, 3 );

The message is:

Deprecated: contextual_help is deprecated since version 3.3.0! Use get_current_screen()->add_help_tab(), get_current_screen()->remove_help_tab() instead. in /var/www/html/wp-includes/functions.php on line 5088

If I comment out line 52 it goes away.

Settings continuous reload

Thanks for the great service, and plugins. I did want to report an issue. The settings page for the plugin continually reloads when the API key isn't loaded. It just keeps giving an error, and reloading. You can stop the reload with the browser stop button. This is in Wordpress 4.7 in PHP 7 by the way.

Doesn't work with emails send from Event Organiser

I'm using Event Organiser Pro to manage events on a number of sites, and it doesn't seem to like sending mails through SendGrid. On all sites, SendGrid sends fine on its own, and so does EO (if SendGrid isn't installed). However, confirmation emails from EO don't send if SendGrid is installed.

In addition, WP Mail Logger shows the emails as being sent – but they don't ever appear in the SendGrid dashboard, either under 'activity' or any of the failures – making diagnosis rather hard.

Here's the relevant code from /includes/email.php:

function eventorganiser_mail( $email, $subject, $body, $headers = array(), $attachments = array(), $template = 'none' ) {

        /**
         * @ignore
         */
        //$header = apply_filters( 'eventorganiser_email_body_header', '<html><head><style type="text/css">#outlook a{padding: 0;}</style></head><body>' );
        /**
         * @ignore
         */
        //$footer = apply_filters( 'eventorganiser_email_body_header', '</body></html>' );
        //add_filter( 'wp_mail_content_type', 'eventorganiser_email_html_content_type' );

        if ( $template && 'none' != $template ) {
                /**
                 * @ignore
                 */
                //$body = apply_filters( 'eventorganiser_email_template', $body, $template );
        }

        /* And send! */
        $send = wp_mail( $email, $subject, $header.$body.$footer, $headers, $attachments );

        remove_filter( 'wp_mail_content_type', 'eventorganiser_email_html_content_type' );

        return $send;
}


/**
 * Sets email content type to HTML
 *
 * Hooked onto `wp_mail_content_type` inside `eventorganiser_mail` and removes itself.
 *
 * @since 1.0
 * @see eventorganiser_mail()
 * @access private
 * @ignore
 *
 * @return string 'text/HTML'
 */
function eventorganiser_email_html_content_type() {
        return "text/html";
}

Sendgrid plugin is polluting the Global namespace

NOTE: I initially reported this on the WP Plugin support forum for this plugin—I hadn't noticed you had a public repo for it at the time
https://wordpress.org/support/topic/sendgrid-plugin-is-polluting-the-global-namespace

Specifically, line 13 of wpsendgrid.php is setting a global variable $plugin:

$plugin = plugin_basename( __FILE__ );

As it happens another plugin we're using looks for that variable name, assuming it was set in the WP loop that loads plugins. (We'll be reporting that as a defect to them as well, of course :) ). However, since we're actually loading both Sendgrid and this other plugin as network-wide plugins (loaded in a different loop), the $plugin variable is present because it was instantiated in the Sendgrid plugin... Boom, Crash, etc. :)

Simply removing that definition on line 13 and passing the value directly on line 60 resolves the issue:
currently :
new Sendgrid_Settings( $plugin );

becomes:
new Sendgrid_Settings( plugin_basename( __FILE__ ) );

Full diff:

--- /sendgrid-email-delivery-simplified/wpsendgrid.php
+++ /sendgrid-email-delivery-simplified/wpsendgrid.php (unsaved)
@@ -9,8 +9,6 @@
 Text Domain: sendgrid-email-delivery-simplified
 License: GPLv2
 */
-
-$plugin = plugin_basename( __FILE__ );

 if ( version_compare( phpversion(), '5.3.0', '<' ) ) {
   add_action( 'admin_notices', 'php_version_error' );
@@ -57,7 +55,7 @@
   require_once plugin_dir_path( __FILE__ ) . '/lib/class-sendgrid-smtp.php';

   // Initialize SendGrid Settings
-  new Sendgrid_Settings( $plugin );
+  new Sendgrid_Settings( plugin_basename( __FILE__ ) );

   // Initialize SendGrid Statistics
   new Sendgrid_Statistics();

Sending bulk email, hiding to address

Is it possible to send an email to a list of recipients, but hide these from each other. Using the SendGrid API this is achieved using the X-SMTPAPI header but I can't see an obvious way of doing this via wp_mail().

Cannot use object of type WP_Error as array

I'm receiving an intermittent error when using SendGrid's WP plugin on one of my sites:

Fatal error: Cannot use object of type WP_Error as array in ~/public_html/wp-content/plugins/sendgrid-email-delivery-simplified/lib/sendgrid/class-sendgrid-api.php on line 52

Seems to point to this line, which was added relatively recently. Previous PR #19 seems to have solved an identical problem in the past, so I'm submitting #29 for your consideration.

Defining SendGrid API Key in WP config Returns - API Key is empty.

When I have the API Key defined in wp-config.php and save the SendGrid settings I get a message saying that API Key is empty. All of the other values defined in wp-config are working.
When I use the same API Key via the settings GUI it works.

define('SENDGRID_API_KEY', 'SG.APIKEY');

problem with Official PHP Client Library

i am using this plugin to send my wordpress mails via sendgrid. works perfectly. in my themes function.php file i want to do some custom api calls (get all bounces).

therefore i included the sendgrid php api library (github.com/sendgrid/sendgrid-php) via require_once in my functions.php file.

i get the following error

FastCGI sent in stderr: "PHP message: PHP Fatal error: Cannot declare class SendGrid\Email, because the name is already in use in /var/www/vhosts/xxx/wp-content/themes/xxx/vendor/sendgrid-php/lib/helpers/mail/Mail.php on line 877" while reading response header from upstream

when i deactivate the sendpress wordpress plugin, everything works fine. when i rename the Mail class in sendgrid-php/lib/helpers/mail/Mail.php on line 877 (in the Official PHP Client Library) it works also.

Subscription Widget Email Confirmation link errors when hosting with Pantheon

I have discovered that if you are hosting on Pantheon the email confirmation link (opt-in) that is sent to a newsletter subscriber errors out. A user is still subscribed but they never get the confirmation page or any of the virtual pages due to a redirect loop. It's caused by Pantheon replacing __sg_api=1 with __sg_api=PANTHEON_REPLACED. This is some sort of caching function on Pantheon. They make exceptions for Google UTM codes but not Sendgrid. I fixed mine by removing one underscore for every instance of __sg_api in class-sendgrid-mc-optin.php.

Incompatible with Forms from Huge-IT

I'm getting this in my log. The form works fine without sendgrid, if I add sendgrid plugin I get this...

// if you use this, it's broken
https://wordpress.org/plugins/forms-contact/

[Tue Apr 05 05:38:57.938858 2016] [:error] [pid 32296] [client 67.180.193.24:34775] PHP Fatal error: Cannot redeclare set_html_content_type() (previously declared in /nas/content/live/vrrockstars/wp-content/plugins/sendgrid-email-delivery-simplified/lib/sendgrid/sendgrid-wp-mail.php:362) in /nas/content/live/vrrockstars/wp-content/plugins/forms-contact/hugeit_contact_function/huge_it_contact_form_validation.php on line 318, referer: http://www.vrrockstars.com/contact-us/

Reset password link being incorrectly encoded

This is specifically to do with using Restrict Content Pro. Without the plugin activated it works, with the plugin it does not.

The URL is created in Restrict Content Pro here: https://github.com/restrictcontentpro/restrict-content-pro/blob/master/includes/login-functions.php#L284

This produces the following link:

rcp_action=lostpassword_reset&key=fZGz3AJAEt9dnVitYlXF&login=test

However when it runs through the SendGrid plugin this results in:

?rcp_action=lostpassword_reset#038;key=hD67EwiCG0csDHOo7rJa&login=test

So the & is being replaced with a #38;

Ensure priority load and setting up

The plugin loads itself too late.

For example, Restrict Content Pro adds this hook add_action('init', 'rcp_process_lostpassword_form') to send email in some cases. But it does not work, because Sendgrid is not yet loaded. I needed to remove the action and add it back with priority 999 to get emails out.

Widget configuration error in combination with Beaver Builder

Hi,

I am using beaver builder (https://www.wpbeaverbuilder.com) with this plugin.
Adding the subscription widget is working, but when you try to configure it, it gives an error (in the console):
Error: Syntax error, unrecognized expression: #fl-field-widget-sendgrid_nlvx_widget type=" on line 2 of https://academy.haagsemakers.nl/wp-includes/js/jquery/jquery.js?ver=1.12.4.

Do you have any ideas on how to fix this?

Custom unsubscribe group

Hello.
We use plugin with version 1.11.8.
We use it with wp_mail mail function (redifined on plugin), and all work fine, but we receive new task:

some mails need to send with custom unsubscribe group.

Yes, we can reconfigure it in plugin options. But in this way every mail sends with it. We need some only.

Yes, we can define SENDGRID_UNSUBSCRIBE_GROUP before wp_mail call. But we cant undefine SENDGRID_UNSUBSCRIBE_GROUP after call. And if wp send any other emails after out mail - they are sent with this constant. Not fine.

No, we not have any way to tell wp_mail send only this mail with this unsubscribe group.

Can you add it in you plugin (i.e. add sendgrid_unsubscribe_group_id in $headers of wp_mail)?

Please add support for dynamic templates.

Build a dynamic template that uses the dynamic_template_data{} structure..

Send an email with the WP plugin using that template.. none of the handlebars placeholders in the template are populated.

Username validation too strict

My sendgrid username (email address) contains a + symbol. I cannot use this plugin without first disabling validation. Consider allowing the + symbol in usernames.

Heroku addon and confusion over username/password deprecation

Hi folks,

Unfortunately spent a few hours on this one.

I installed WP on Heroku, added SendGrid addon, and for the life of me couldn't understand why it wouldn't work. I started researching whether I set my ENV variables correctly (taken from an example wordpress-on-heroku app):

  define('SENDGRID_AUTH_METHOD', 'credentials');
  define('SENDGRID_USERNAME', getenv('SENDGRID_USERNAME'));
  define('SENDGRID_PASSWORD', getenv('SENDGRID_PASSWORD'));
  define('SENDGRID_SEND_METHOD', 'api');
  define('SENDGRID_FROM_NAME', 'Example Name');
  define('SENDGRID_FROM_EMAIL', '[email protected]');
  define('SENDGRID_REPLY_TO', '[email protected]');

and while doing research, I found that there is not a single mention of SENDGRID_AUTH_METHOD anywhere in this repo when you search it on github. (Mentioning it in this issue for future searches).

It took me way too long to find out that as of 1.11.x credentials (username/password) are no longer supported. It was weird, because your Heroku addon specifically adds those 2 things to ENV vars, and does not add an API key. However then I found that in Heroku docs you tell people to create the API key manually.

The manual step really puts a stick in the wheels of our automated infrastructure for new apps.

I would like to both inform others to use 1.10.9 if they want automated Heroku integration, and to ask the team — please make Heroku addon auto-create SENDGRID_API_KEY when installed. It would help make things automated, and I'm sure clear up some confusion.

Custom arguments truncated to one character

I'm adding custom arguments into the header, all is fine until it hits the foreach loop here: https://github.com/sendgrid/wordpress/blob/master/lib/sendgrid/class-sendgrid-translator.php#L415

As you can see it checks if there's an index, which in my case is always 0, and so it pulls the first character from the string and passes that along instead of the entire string. Should it be also checking if it's an array and isset index, else it just passes on the whole value?

BuddyPress From Email Change

I have a filter set to change the Personal Messages from address for just BuddyPress emails, but it's still sending from my default WP email address.

add_action( 'bp_email', function( $email_type, $email_obj ) { $email_obj->set_from( "[email protected]", "PM Notification" ); }, 100, 2 );

I can see that there are some customizations within the plugin for BuddyPress, but I'm not sure how to work with them.

Confirmation textarea has no way to insert formatted unsubscribe link?

The "Signup email content" textareas in the settings don't appear to offer a way to customize placement of the unsubscribe link that is required by CAN-SPAM/SendGrid and the result is that the link is automatically inserted at the very end of the email and you get something like this:

unsubscribe-link-problem

That's not very professional looking, my clients don't want them to go out that way.

The %confirmation_link% template tag is working to insert the proper confirmation URL. Is there a way to get the unsubscribe URL as well, so the SendGrid app won't automatically insert whatever it wants at the end of the email?

I've looked in the SendGrid control panel and couldn't find an unsubscribe URL anywhere but in a builder tag and those don't work in this plugin. Is it possible to manually construct an unsubscribe URL?

This plugin is sniffing and adding vars to posted data..and can cause issues

I found out the hardway and lost 4 days finding this...yikes.

In this file you will see it sniffing and adding variables:
https://github.com/sendgrid/wordpress/blob/master/lib/class-sendgrid-mc-optin.php

This becomes an issue in home_url scenarios, it can cause the jquery .load function to fail.

This sendgrid service is very valuable, so to keep using the service with this plugin, you can simply comment out all includes that reference this file in the files:

lib/class-sendgrid-settings.php
wpsendgrid.php

This will effect their opt-in widget, but there are other options that might be better and updated for doing opt-in widgets.

Subscribe success page redirect uses post guid

Guid's are not a good source of redirect URL... in time the actual domain/url of the page can change but the GUID by definition will not... this has caused me trouble in a site where we configured in a subdomain (staging.xxx.com) and then deployed... the guid stayed as staging.xxx.com...

In class_sendgrid_tools ...

 /**
   * Return the value for the signup confirmation page url
   *
   * @return  mixed   signup confirmation page url, false if the value is not found
   */
  public static function get_mc_signup_confirmation_page_url()
  {
    $page_id = self::get_mc_signup_confirmation_page();
    if ( false == $page_id or 'default' == $page_id ) {
      return false;
    }

    $confirmation_pages = get_pages( array( 'parent' => 0 ) );
    foreach ( $confirmation_pages as $key => $page ) {
      if ( $page->ID == $page_id ) {
        return $page->guid;
      }
    }

    return false;
  }

return $page->guid should be refactored...

I don't know wordpress much but would'nt get_permalink() be a better choice?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.