SendGrid - Version 1.6.5

Version Description

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

Release Info

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

Code changes from version 1.6.4 to 1.6.5

assets/screenshot-9.png ADDED
Binary file
lib/class-sendgrid-settings.php CHANGED
@@ -36,10 +36,16 @@ class Sendgrid_Settings
36
  if ( isset( $_POST['email_test'] ) and $_POST['email_test'] )
37
  {
38
  $to = $_POST['sendgrid_to'];
39
- $subject = $_POST['sendgrid_subj'];
40
- $body = $_POST['sendgrid_body'];
41
  $headers = $_POST['sendgrid_headers'];
42
- $sent = wp_mail($to, $subject, $body, $headers);
 
 
 
 
 
 
43
  if ( 'api' == Sendgrid_Tools::get_send_method() )
44
  {
45
  $sent = json_decode( $sent['body'] );
@@ -126,6 +132,11 @@ class Sendgrid_Settings
126
  update_option('sendgrid_auth_method', $auth_method);
127
  }
128
 
 
 
 
 
 
129
  if ( ! isset( $status ) or ( isset( $status ) and ( $status != 'error' ) ) ) {
130
  $message = 'Options saved.';
131
  $status = 'updated';
@@ -156,10 +167,11 @@ class Sendgrid_Settings
156
  $api_key = Sendgrid_Tools::get_api_key();
157
  $method = Sendgrid_Tools::get_send_method();
158
  $auth_method = Sendgrid_Tools::get_auth_method();
159
- $name = Sendgrid_Tools::get_from_name();
160
  $email = Sendgrid_Tools::get_from_email();
161
  $reply_to = Sendgrid_Tools::get_reply_to();
162
- $categories = Sendgrid_Tools::get_categories();
 
163
 
164
  $allowed_methods = array('smtp', 'api');
165
  if (!in_array($method, $allowed_methods))
@@ -191,6 +203,7 @@ class Sendgrid_Settings
191
 
192
  $are_global_credentials = ( defined('SENDGRID_USERNAME') and defined('SENDGRID_PASSWORD') );
193
  $is_global_api_key = defined('SENDGRID_API_KEY');
 
194
 
195
  require_once dirname( __FILE__ ) . '/../view/sendgrid_settings.php';
196
  }
36
  if ( isset( $_POST['email_test'] ) and $_POST['email_test'] )
37
  {
38
  $to = $_POST['sendgrid_to'];
39
+ $subject = stripslashes( $_POST['sendgrid_subj'] );
40
+ $body = stripslashes( $_POST['sendgrid_body'] );
41
  $headers = $_POST['sendgrid_headers'];
42
+ if ( preg_match( "/content-type:\s*text\/html/i", $headers ) ) {
43
+ $body_br = nl2br( $body );
44
+ } else {
45
+ $body_br = $body;
46
+ }
47
+
48
+ $sent = wp_mail($to, $subject, $body_br, $headers);
49
  if ( 'api' == Sendgrid_Tools::get_send_method() )
50
  {
51
  $sent = json_decode( $sent['body'] );
132
  update_option('sendgrid_auth_method', $auth_method);
133
  }
134
 
135
+ if ( isset( $_POST['sendgrid_port'] ) ) {
136
+ $port = $_POST['sendgrid_port'];
137
+ update_option('sendgrid_port', $port);
138
+ }
139
+
140
  if ( ! isset( $status ) or ( isset( $status ) and ( $status != 'error' ) ) ) {
141
  $message = 'Options saved.';
142
  $status = 'updated';
167
  $api_key = Sendgrid_Tools::get_api_key();
168
  $method = Sendgrid_Tools::get_send_method();
169
  $auth_method = Sendgrid_Tools::get_auth_method();
170
+ $name = stripslashes( Sendgrid_Tools::get_from_name() );
171
  $email = Sendgrid_Tools::get_from_email();
172
  $reply_to = Sendgrid_Tools::get_reply_to();
173
+ $categories = stripslashes( Sendgrid_Tools::get_categories() );
174
+ $port = Sendgrid_Tools::get_port();
175
 
176
  $allowed_methods = array('smtp', 'api');
177
  if (!in_array($method, $allowed_methods))
203
 
204
  $are_global_credentials = ( defined('SENDGRID_USERNAME') and defined('SENDGRID_PASSWORD') );
205
  $is_global_api_key = defined('SENDGRID_API_KEY');
206
+ $has_port = defined('SENDGRID_PORT');
207
 
208
  require_once dirname( __FILE__ ) . '/../view/sendgrid_settings.php';
209
  }
lib/class-sendgrid-tools.php CHANGED
@@ -159,6 +159,20 @@ class Sendgrid_Tools
159
  }
160
  }
161
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
162
  /**
163
  * Return auth method from the database or global variable
164
  *
159
  }
160
  }
161
 
162
+ /**
163
+ * Return port from the database or global variable
164
+ *
165
+ * @return string port
166
+ */
167
+ public static function get_port()
168
+ {
169
+ if ( defined('SENDGRID_PORT') ) {
170
+ return SENDGRID_PORT;
171
+ } else {
172
+ return get_option('sendgrid_port');
173
+ }
174
+ }
175
+
176
  /**
177
  * Return auth method from the database or global variable
178
  *
lib/overwrite-sendgrid-methods.php CHANGED
@@ -427,7 +427,10 @@ if ( ! function_exists('wp_mail'))
427
  if ( class_exists('Swift') )
428
  {
429
  $smtp = new SGSmtp( Sendgrid_Tools::get_username(), Sendgrid_Tools::get_password() );
430
-
 
 
 
431
  return $smtp->send( $mail );
432
  }
433
  else
427
  if ( class_exists('Swift') )
428
  {
429
  $smtp = new SGSmtp( Sendgrid_Tools::get_username(), Sendgrid_Tools::get_password() );
430
+ if ( Sendgrid_Tools::get_port() ) {
431
+ $smtp->setPort( Sendgrid_Tools::get_port() );
432
+ }
433
+
434
  return $smtp->send( $mail );
435
  }
436
  else
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.3
7
- Stable tag: 1.6.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -120,9 +120,12 @@ Create a SendGrid account at <a href="http://sendgrid.com/partner/wordpress" tar
120
  6. Header provided in the send test email form.
121
  7. 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.
122
  8. Select the time interval for which you want to see SendGrid statistics and charts.
 
123
 
124
  == Changelog ==
125
 
 
 
126
  = 1.6.4 =
127
  * Add support for toName in API method, Add required Text Domain
128
  = 1.6.3 =
@@ -180,6 +183,8 @@ Create a SendGrid account at <a href="http://sendgrid.com/partner/wordpress" tar
180
 
181
  == Upgrade notice ==
182
 
 
 
183
  = 1.6.4 =
184
  * Add support for toName in API method, Add required Text Domain
185
  = 1.6.3 =
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.3
7
+ Stable tag: 1.6.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
120
  6. Header provided in the send test email form.
121
  7. 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.
122
  8. Select the time interval for which you want to see SendGrid statistics and charts.
123
+ 9. Now you are able to configure port number when using SMTP method.
124
 
125
  == Changelog ==
126
 
127
+ = 1.6.5 =
128
+ * Add configurable port number for SMTP method, Specify full path for sendgrid php library, Fix special characters and new lines issues
129
  = 1.6.4 =
130
  * Add support for toName in API method, Add required Text Domain
131
  = 1.6.3 =
183
 
184
  == Upgrade notice ==
185
 
186
+ = 1.6.5 =
187
+ * Add configurable port number for SMTP method, Specify full path for sendgrid php library, Fix special characters and new lines issues
188
  = 1.6.4 =
189
  * Add support for toName in API method, Add required Text Domain
190
  = 1.6.3 =
vendor/sendgrid-php/sendgrid-php.php CHANGED
@@ -1,4 +1,4 @@
1
  <?php
2
- require 'vendor/autoload.php';
3
- require 'lib/SendGrid.php';
4
  ?>
1
  <?php
2
+ require __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
3
+ require __DIR__ . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'SendGrid.php';
4
  ?>
view/js/sendgrid.settings.js CHANGED
@@ -5,26 +5,47 @@ jQuery(document).ready(function($) {
5
  $(".creds").hide();
6
  $("#sendgrid_api").val('api');
7
  $("#sendgrid_api #smtp").hide();
 
8
  } else {
9
  $(".apikey").hide();
10
  $(".creds").show();
11
  $("#sendgrid_api #smtp").show();
 
12
  }
13
 
14
  var method = $('#sendgrid_api').find("option:selected").val();
15
  $('#auth_method').change(function() {
16
  authMethod = $(this).find("option:selected").val();
17
  if ( authMethod == 'apikey' ) {
18
- $(".apikey").show();
19
- $(".creds").hide();
20
- $("#sendgrid_api").val('api');
21
- $("#sendgrid_api #smtp").hide();
 
22
  } else {
23
- $(".apikey").hide();
24
- $(".creds").show();
25
- $('#sendgrid_api').val(method);
26
- $("#sendgrid_api #smtp").show();
27
- $("#sendgrid_api").find("#"+method).attr("selected", "selected");
 
 
 
28
  }
29
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  });
5
  $(".creds").hide();
6
  $("#sendgrid_api").val('api');
7
  $("#sendgrid_api #smtp").hide();
8
+ $(".port").hide();
9
  } else {
10
  $(".apikey").hide();
11
  $(".creds").show();
12
  $("#sendgrid_api #smtp").show();
13
+ $(".port").show();
14
  }
15
 
16
  var method = $('#sendgrid_api').find("option:selected").val();
17
  $('#auth_method').change(function() {
18
  authMethod = $(this).find("option:selected").val();
19
  if ( authMethod == 'apikey' ) {
20
+ $(".apikey").show();
21
+ $(".creds").hide();
22
+ $(".port").hide();
23
+ $("#sendgrid_api").val('api');
24
+ $("#sendgrid_api #smtp").hide();
25
  } else {
26
+ $(".apikey").hide();
27
+ $(".creds").show();
28
+ if (method == 'smtp') {
29
+ $(".port").show();
30
+ }
31
+ $('#sendgrid_api').val(method);
32
+ $("#sendgrid_api #smtp").show();
33
+ $("#sendgrid_api").find("#"+method).attr("selected", "selected");
34
  }
35
  });
36
+
37
+ $('#sendgrid_api').change(function() {
38
+ sendMethod = $(this).find("option:selected").val();
39
+ if ( sendMethod == 'api' ) {
40
+ $(".port").hide();
41
+ } else {
42
+ $(".port").show();
43
+ }
44
+ });
45
+
46
+ if ( method == 'api' ) {
47
+ $(".port").hide();
48
+ } else {
49
+ $(".port").show();
50
+ }
51
  });
view/sendgrid_settings.php CHANGED
@@ -62,6 +62,16 @@
62
  </select>
63
  </td>
64
  </tr>
 
 
 
 
 
 
 
 
 
 
65
  </tbody>
66
  </table>
67
  <br />
62
  </select>
63
  </td>
64
  </tr>
65
+ <tr valign="top" class="port">
66
+ <th scope="row"><?php _e("PORT: "); ?></th>
67
+ <td>
68
+ <select name="sendgrid_port" id="sendgrid_port" <?php disabled( $has_port ); ?>>
69
+ <option value="<?php echo SGSmtp::TLS ?>" id="tls" <?php echo ( ( SGSmtp::TLS == $port ) or (! $port ) ) ? 'selected' : '' ?>><?php echo SGSmtp::TLS ?></option>
70
+ <option value="<?php echo SGSmtp::TLS_ALTERNATIVE ?>" id="tls_alt" <?php echo ( SGSmtp::TLS_ALTERNATIVE == $port ) ? 'selected' : '' ?>><?php echo SGSmtp::TLS_ALTERNATIVE ?></option>
71
+ <option value="<?php echo SGSmtp::SSL ?>" id="ssl" <?php echo ( SGSmtp::SSL == $port ) ? 'selected' : '' ?>><?php echo SGSmtp::SSL ?></option>
72
+ </select>
73
+ </td>
74
+ </tr>
75
  </tbody>
76
  </table>
77
  <br />
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.6.4
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.6.5
7
  Author: SendGrid
8
  Author URI: http://sendgrid.com
9
  Text Domain: sendgrid-email-delivery-simplified