SendGrid - Version 1.8.1

Version Description

  • Added possibility to override the email template
Download this release

Release Info

Developer team-rs
Plugin Icon 128x128 SendGrid
Version 1.8.1
Comparing to
See all releases

Code changes from version 1.8.0 to 1.8.1

lib/class-sendgrid-settings.php CHANGED
@@ -379,7 +379,7 @@ class Sendgrid_Settings {
379
 
380
  return array(
381
  'message' => 'Email wasn\'t sent.',
382
- 'status' => 'updated',
383
  'error_type' => 'sending'
384
  );
385
  }
379
 
380
  return array(
381
  'message' => 'Email wasn\'t sent.',
382
+ 'status' => 'error',
383
  'error_type' => 'sending'
384
  );
385
  }
lib/sendgrid/sendgrid-wp-mail.php CHANGED
@@ -78,11 +78,6 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array()
78
  }
79
  }
80
 
81
- $template = Sendgrid_Tools::get_template();
82
- if ( $template) {
83
- $mail->setTemplateId( $template );
84
- }
85
-
86
  // Headers
87
  $cc = array();
88
  $bcc = array();
@@ -256,6 +251,10 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array()
256
  if (! $from_email) {
257
  // Get the site domain and get rid of www.
258
  $sitename = strtolower( $_SERVER['SERVER_NAME'] );
 
 
 
 
259
  if ( 'www.' == substr( $sitename, 0, 4 ) ) {
260
  $sitename = substr( $sitename, 4 );
261
  }
@@ -319,6 +318,15 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array()
319
  }
320
  }
321
 
 
 
 
 
 
 
 
 
 
322
  $content_type = apply_filters( 'wp_mail_content_type', $content_type );
323
 
324
  $mail->setSubject( $subject )
78
  }
79
  }
80
 
 
 
 
 
 
81
  // Headers
82
  $cc = array();
83
  $bcc = array();
251
  if (! $from_email) {
252
  // Get the site domain and get rid of www.
253
  $sitename = strtolower( $_SERVER['SERVER_NAME'] );
254
+ if ( ! $sitename and ( 'smtp' == $method ) ) {
255
+ return false;
256
+ }
257
+
258
  if ( 'www.' == substr( $sitename, 0, 4 ) ) {
259
  $sitename = substr( $sitename, 4 );
260
  }
318
  }
319
  }
320
 
321
+ if( ! array_key_exists( 'sendgrid_override_template' , $GLOBALS['wp_filter'] ) ) {
322
+ $template = Sendgrid_Tools::get_template();
323
+ if ( $template ) {
324
+ $mail->setTemplateId( $template );
325
+ }
326
+ } else {
327
+ $message = apply_filters( 'sendgrid_override_template', $message, $content_type );
328
+ }
329
+
330
  $content_type = apply_filters( 'wp_mail_content_type', $content_type );
331
 
332
  $mail->setSubject( $subject )
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://sendgrid.com/
4
  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
5
  Requires at least: 3.3
6
  Tested up to: 4.4
7
- Stable tag: 1.8.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -120,6 +120,15 @@ $mail = wp_mail($to, $subject, $message, $headers);`
120
 
121
  More examples for using SendGrid SMTPAPI header: <https://github.com/sendgrid/sendgrid-php#smtpapi>
122
 
 
 
 
 
 
 
 
 
 
123
  == Installation ==
124
 
125
  Requirements:
@@ -127,6 +136,7 @@ Requirements:
127
  1. PHP version >= 5.3.0
128
  2. You need to have PHP-curl extension enabled in order to send attachments.
129
  3. To send emails through SMTP you need to install also the 'Swift Mailer' plugin.
 
130
 
131
  To upload the SendGrid Plugin .ZIP file:
132
 
@@ -166,6 +176,32 @@ SendGrid settings can optionally be defined as global variables (wp-config.php):
166
 
167
  Create a SendGrid account at <a href="http://sendgrid.com/partner/wordpress" target="_blank">https://sendgrid.com/partner/wordpress</a> and generate a new API key on <https://app.sendgrid.com/settings/api_keys>.
168
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
  == Screenshots ==
170
 
171
  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.
@@ -183,6 +219,8 @@ Create a SendGrid account at <a href="http://sendgrid.com/partner/wordpress" tar
183
 
184
  == Changelog ==
185
 
 
 
186
  = 1.8.0 =
187
  * Added SendGrid\Email() for $header
188
  * Fix Send Test form not being displayed issue
@@ -283,6 +321,8 @@ Create a SendGrid account at <a href="http://sendgrid.com/partner/wordpress" tar
283
 
284
  == Upgrade notice ==
285
 
 
 
286
  = 1.8.0 =
287
  * Added SendGrid\Email() for $header
288
  * Fix Send Test form not being displayed issue
4
  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
5
  Requires at least: 3.3
6
  Tested up to: 4.4
7
+ Stable tag: 1.8.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
120
 
121
  More examples for using SendGrid SMTPAPI header: <https://github.com/sendgrid/sendgrid-php#smtpapi>
122
 
123
+ = Using categories =
124
+
125
+ Categories used for emails can be set:
126
+
127
+ * globally, for all emails sent, by setting the 'Categories' field in the 'Mail settings' section
128
+ * per email by adding the category in the headers array: `$headers[] = 'categories: category1, category2';`
129
+
130
+ If you would like to configure categories for statistics, you can configure it by setting the 'Categories' field in the 'Statistics settings' section
131
+
132
  == Installation ==
133
 
134
  Requirements:
136
  1. PHP version >= 5.3.0
137
  2. You need to have PHP-curl extension enabled in order to send attachments.
138
  3. To send emails through SMTP you need to install also the 'Swift Mailer' plugin.
139
+ 4. If wp_mail() function has been declared by another plugin that you have installed, you won't be able to use the SendGrid plugin
140
 
141
  To upload the SendGrid Plugin .ZIP file:
142
 
176
 
177
  Create a SendGrid account at <a href="http://sendgrid.com/partner/wordpress" target="_blank">https://sendgrid.com/partner/wordpress</a> and generate a new API key on <https://app.sendgrid.com/settings/api_keys>.
178
 
179
+ = How can I define a plugin setting to be used for all sites =
180
+
181
+ Add it into your wp-config.php file. Example: `define('SENDGRID_API_KEY', 'your_api_key');`.
182
+
183
+ = How to use SendGrid with WP Better Emails plugin =
184
+
185
+ 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:
186
+
187
+ `function use_wpbe_template( $message, $content_type ) {
188
+ global $wp_better_emails;
189
+ if ( 'text/plain' == $content_type ) {
190
+ $message = $wp_better_emails->process_email_text( $message );
191
+ } else {
192
+ $message = $wp_better_emails->process_email_html( $message );
193
+ }
194
+
195
+ return $message;
196
+ }
197
+ add_filter( 'sendgrid_override_template', 'use_wpbe_template', 10, 2 );`
198
+
199
+ 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.
200
+
201
+ = Why are my emails sent as HTML instead of plain text =
202
+
203
+ For a detailed explanation see this page: https://support.sendgrid.com/hc/en-us/articles/200181418-Plain-text-emails-converted-to-HTML
204
+
205
  == Screenshots ==
206
 
207
  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.
219
 
220
  == Changelog ==
221
 
222
+ = 1.8.1 =
223
+ * Added possibility to override the email template
224
  = 1.8.0 =
225
  * Added SendGrid\Email() for $header
226
  * Fix Send Test form not being displayed issue
321
 
322
  == Upgrade notice ==
323
 
324
+ = 1.8.1 =
325
+ * Added possibility to override the email template
326
  = 1.8.0 =
327
  * Added SendGrid\Email() for $header
328
  * Fix Send Test form not being displayed issue
view/sendgrid_contextual_help.php CHANGED
@@ -164,6 +164,14 @@
164
  More examples for using SendGrid SMTPAPI header: <a href="https://github.com/sendgrid/sendgrid-php#smtpapi" target="_blank">https://github.com/sendgrid/sendgrid-php#smtpapi</a>
165
  <br />
166
  <br />
 
 
 
 
 
 
 
 
167
  <p><b>Define SendGrid settings as global variables (wp-config.php):</b></p>
168
  <p>
169
  <ol>
164
  More examples for using SendGrid SMTPAPI header: <a href="https://github.com/sendgrid/sendgrid-php#smtpapi" target="_blank">https://github.com/sendgrid/sendgrid-php#smtpapi</a>
165
  <br />
166
  <br />
167
+ <b>Categories used for emails can be set:</b>
168
+ <ul>
169
+ <li>globally, for all emails sent, by setting the 'Categories' field in the 'Mail settings' section</li>
170
+ <li>per email by adding the category in the headers array: <span class="code">$headers[] = 'categories: category1, category2';</span></li>
171
+ </ul>
172
+ If you would like to configure categories for statistics, you can configure it by setting the 'Categories' field in the 'Statistics settings' section
173
+ <br />
174
+ <br />
175
  <p><b>Define SendGrid settings as global variables (wp-config.php):</b></p>
176
  <p>
177
  <ol>
wpsendgrid.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: SendGrid
4
  Plugin URI: http://wordpress.org/plugins/sendgrid-email-delivery-simplified/
5
  Description: Email Delivery. Simplified. SendGrid's cloud-based email infrastructure relieves businesses of the cost and complexity of maintaining custom email systems. SendGrid provides reliable delivery, scalability and real-time analytics along with flexible APIs that make custom integration a breeze.
6
- Version: 1.8.0
7
  Author: SendGrid
8
  Author URI: http://sendgrid.com
9
  Text Domain: sendgrid-email-delivery-simplified
3
  Plugin Name: SendGrid
4
  Plugin URI: http://wordpress.org/plugins/sendgrid-email-delivery-simplified/
5
  Description: Email Delivery. Simplified. SendGrid's cloud-based email infrastructure relieves businesses of the cost and complexity of maintaining custom email systems. SendGrid provides reliable delivery, scalability and real-time analytics along with flexible APIs that make custom integration a breeze.
6
+ Version: 1.8.1
7
  Author: SendGrid
8
  Author URI: http://sendgrid.com
9
  Text Domain: sendgrid-email-delivery-simplified