SendGrid - Version 1.6.2

Version Description

  • Add Api Keys for authentication, use the last version of Sendgrid library: https://github.com/sendgrid/sendgrid-php/releases/tag/v3.2.0
Download this release

Release Info

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

Code changes from version 1.6.1 to 1.6.2

Files changed (51) hide show
  1. assets/screenshot-3.png +0 -0
  2. assets/screenshot-4.png +0 -0
  3. assets/screenshot-5.png +0 -0
  4. assets/screenshot-6.png +0 -0
  5. assets/screenshot-7.png +0 -0
  6. assets/screenshot-8.png +0 -0
  7. lib/class-sendgrid-settings.php +80 -32
  8. lib/class-sendgrid-statistics.php +10 -6
  9. lib/class-sendgrid-tools.php +85 -5
  10. lib/overwrite-sendgrid-methods.php +30 -13
  11. readme.txt +11 -6
  12. vendor/sendgrid-php/CHANGELOG.md +9 -0
  13. vendor/sendgrid-php/README.md +18 -6
  14. vendor/sendgrid-php/composer.lock +14 -15
  15. vendor/sendgrid-php/lib/SendGrid.php +73 -22
  16. vendor/sendgrid-php/lib/SendGrid/Email.php +105 -35
  17. vendor/sendgrid-php/lib/SendGrid/Exception.php +4 -4
  18. vendor/sendgrid-php/lib/SendGrid/Response.php +3 -4
  19. vendor/sendgrid-php/vendor/autoload.php +1 -1
  20. vendor/sendgrid-php/vendor/composer/autoload_namespaces.php +0 -1
  21. vendor/sendgrid-php/vendor/composer/autoload_psr4.php +1 -0
  22. vendor/sendgrid-php/vendor/composer/autoload_real.php +4 -4
  23. vendor/sendgrid-php/vendor/composer/installed.json +14 -15
  24. vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/CHANGELOG.md → CHANGELOG.md} +0 -0
  25. vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php → ContainerAwareEventDispatcher.php} +1 -1
  26. vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/Debug → Debug}/TraceableEventDispatcher.php +18 -3
  27. vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/Debug → Debug}/TraceableEventDispatcherInterface.php +0 -0
  28. vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/Debug → Debug}/WrappedListener.php +0 -0
  29. vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/DependencyInjection → DependencyInjection}/RegisterListenersPass.php +0 -0
  30. vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/Event.php → Event.php} +8 -4
  31. vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/EventDispatcher.php → EventDispatcher.php} +1 -1
  32. vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/EventDispatcherInterface.php → EventDispatcherInterface.php} +1 -1
  33. vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/EventSubscriberInterface.php → EventSubscriberInterface.php} +0 -0
  34. vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/GenericEvent.php → GenericEvent.php} +1 -1
  35. vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php → ImmutableEventDispatcher.php} +0 -0
  36. vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/LICENSE → LICENSE} +0 -0
  37. vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/README.md → README.md} +0 -0
  38. vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/Tests → Tests}/AbstractEventDispatcherTest.php +18 -2
  39. vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/Tests → Tests}/ContainerAwareEventDispatcherTest.php +0 -0
  40. vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/Tests → Tests}/Debug/TraceableEventDispatcherTest.php +14 -0
  41. vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/Tests → Tests}/DependencyInjection/RegisterListenersPassTest.php +0 -0
  42. vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/Tests → Tests}/EventDispatcherTest.php +0 -0
  43. vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/Tests → Tests}/EventTest.php +0 -0
  44. vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/Tests → Tests}/GenericEventTest.php +0 -0
  45. vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/Tests → Tests}/ImmutableEventDispatcherTest.php +0 -0
  46. vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/phpunit.xml.dist → phpunit.xml.dist} +1 -0
  47. view/css/sendgrid.css +4 -0
  48. view/js/sendgrid.settings.js +30 -0
  49. view/js/sendgrid.stats.js +1 -0
  50. view/sendgrid_settings.php +26 -8
  51. wpsendgrid.php +1 -1
assets/screenshot-3.png CHANGED
Binary file
assets/screenshot-4.png CHANGED
Binary file
assets/screenshot-5.png CHANGED
Binary file
assets/screenshot-6.png CHANGED
Binary file
assets/screenshot-7.png CHANGED
Binary file
assets/screenshot-8.png ADDED
Binary file
lib/class-sendgrid-settings.php CHANGED
@@ -66,25 +66,28 @@ class Sendgrid_Settings
66
  }
67
  }
68
  } else {
69
- $message = 'Options saved.';
70
- $status = 'updated';
71
-
72
- if (isset($_POST['sendgrid_user']))
73
- {
74
- $user = $_POST['sendgrid_user'];
75
- update_option('sendgrid_user', $user);
76
- }
77
-
78
- if (isset($_POST['sendgrid_pwd']))
79
- {
80
- $password = $_POST['sendgrid_pwd'];
81
- update_option('sendgrid_pwd', $password);
82
- }
83
-
84
- if (isset($_POST['sendgrid_api']))
85
- {
86
- $method = $_POST['sendgrid_api'];
87
- update_option('sendgrid_api', $method);
 
 
 
88
  }
89
 
90
  if (isset($_POST['sendgrid_name']))
@@ -110,16 +113,53 @@ class Sendgrid_Settings
110
  $categories = $_POST['sendgrid_categories'];
111
  update_option('sendgrid_categories', $categories);
112
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  }
114
  }
115
 
116
- $user = Sendgrid_Tools::get_username();
117
- $password = Sendgrid_Tools::get_password();
118
- $method = Sendgrid_Tools::get_send_method();
119
- $name = Sendgrid_Tools::get_from_name();
120
- $email = Sendgrid_Tools::get_from_email();
121
- $reply_to = Sendgrid_Tools::get_reply_to();
122
- $categories = Sendgrid_Tools::get_categories();
 
 
123
 
124
  $allowed_methods = array('smtp', 'api');
125
  if (!in_array($method, $allowed_methods))
@@ -135,16 +175,22 @@ class Sendgrid_Settings
135
  $status = 'error';
136
  }
137
 
138
- if ( $user and $password )
139
- {
140
- if ( ! Sendgrid_Tools::check_username_password( $user, $password ) )
141
- {
142
- $message = 'Invalid username/password';
143
- $status = 'error';
 
 
 
 
 
144
  }
145
  }
146
 
147
  $are_global_credentials = ( defined('SENDGRID_USERNAME') and defined('SENDGRID_PASSWORD') );
 
148
 
149
  require_once dirname( __FILE__ ) . '/../view/sendgrid_settings.php';
150
  }
@@ -193,5 +239,7 @@ class Sendgrid_Settings
193
  }
194
 
195
  wp_enqueue_style( 'sendgrid', plugin_dir_url( __FILE__ ) . '../view/css/sendgrid.css' );
 
 
196
  }
197
  }
66
  }
67
  }
68
  } else {
69
+ if ( isset ($_POST['auth_method'] ) ) {
70
+ if ( $_POST['auth_method'] == 'apikey' ) {
71
+ if ( ! $_POST['sendgrid_api_key'] ){
72
+ $message = 'Api key is required';
73
+ $status = 'error';
74
+ } else {
75
+ if ( ! Sendgrid_Tools::check_api_key( $_POST['sendgrid_api_key'] ) ) {
76
+ $message = 'Invalid api key';
77
+ $status = 'error';
78
+ }
79
+ }
80
+ } else {
81
+ if ( ! $_POST['sendgrid_user'] or ! $_POST['sendgrid_pwd'] ) {
82
+ $message = 'Username/Password are required';
83
+ $status = 'error';
84
+ } else {
85
+ if ( ! Sendgrid_Tools::check_username_password( $_POST['sendgrid_user'], $_POST['sendgrid_pwd'] ) ) {
86
+ $message = 'Invalid username/password';
87
+ $status = 'error';
88
+ }
89
+ }
90
+ }
91
  }
92
 
93
  if (isset($_POST['sendgrid_name']))
113
  $categories = $_POST['sendgrid_categories'];
114
  update_option('sendgrid_categories', $categories);
115
  }
116
+
117
+ if (isset($_POST['sendgrid_api']))
118
+ {
119
+ $method = $_POST['sendgrid_api'];
120
+ update_option('sendgrid_api', $method);
121
+ }
122
+
123
+ if (isset($_POST['auth_method']))
124
+ {
125
+ $auth_method = $_POST['auth_method'];
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';
132
+
133
+ if (isset($_POST['sendgrid_api_key']))
134
+ {
135
+ $user = $_POST['sendgrid_api_key'];
136
+ update_option('sendgrid_api_key', $user);
137
+ }
138
+
139
+ if (isset($_POST['sendgrid_user']))
140
+ {
141
+ $user = $_POST['sendgrid_user'];
142
+ update_option('sendgrid_user', $user);
143
+ }
144
+
145
+ if (isset($_POST['sendgrid_pwd']))
146
+ {
147
+ $password = $_POST['sendgrid_pwd'];
148
+ update_option('sendgrid_pwd', $password);
149
+ }
150
+ }
151
  }
152
  }
153
 
154
+ $user = Sendgrid_Tools::get_username();
155
+ $password = Sendgrid_Tools::get_password();
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))
175
  $status = 'error';
176
  }
177
 
178
+ if ( $api_key ) {
179
+ if ( ! Sendgrid_Tools::check_api_key( $api_key ) ) {
180
+ $message = 'Invalid api key';
181
+ $status = 'error';
182
+ }
183
+ } else {
184
+ if ( $user and $password ) {
185
+ if ( ! Sendgrid_Tools::check_username_password( $user, $password ) ) {
186
+ $message = 'Invalid username/password';
187
+ $status = 'error';
188
+ }
189
  }
190
  }
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
  }
239
  }
240
 
241
  wp_enqueue_style( 'sendgrid', plugin_dir_url( __FILE__ ) . '../view/css/sendgrid.css' );
242
+
243
+ wp_enqueue_script( 'sendgrid', plugin_dir_url( __FILE__ ) . '../view/js/sendgrid.settings.js', array('jquery') );
244
  }
245
  }
lib/class-sendgrid-statistics.php CHANGED
@@ -25,7 +25,8 @@ class Sendgrid_Statistics
25
  */
26
  public static function add_dashboard_widget()
27
  {
28
- if ( ! Sendgrid_Tools::check_username_password( Sendgrid_Tools::get_username(), Sendgrid_Tools::get_password() ) ) {
 
29
  return;
30
  }
31
 
@@ -50,7 +51,8 @@ class Sendgrid_Statistics
50
  */
51
  public static function add_statistics_menu()
52
  {
53
- if ( ! Sendgrid_Tools::check_username_password( Sendgrid_Tools::get_username(), Sendgrid_Tools::get_password() ) ) {
 
54
  return;
55
  }
56
 
@@ -111,10 +113,12 @@ class Sendgrid_Statistics
111
  }
112
 
113
  $parameters = array();
114
- $parameters['api_user'] = Sendgrid_Tools::get_username();
115
- $parameters['api_key'] = Sendgrid_Tools::get_password();
 
 
 
116
  $parameters['data_type'] = 'global';
117
- $parameters['metric'] = 'all';
118
 
119
  if ( array_key_exists( 'days', $_POST ) ) {
120
  $parameters['days'] = $_POST['days'];
@@ -131,7 +135,7 @@ class Sendgrid_Statistics
131
  }
132
  }
133
 
134
- echo Sendgrid_Tools::curl_request( 'api/stats.get.json', $parameters );
135
 
136
  die();
137
  }
25
  */
26
  public static function add_dashboard_widget()
27
  {
28
+ if ( ! Sendgrid_Tools::check_username_password( Sendgrid_Tools::get_username(), Sendgrid_Tools::get_password() )
29
+ and ! Sendgrid_Tools::check_api_key( Sendgrid_Tools::get_api_key() ) ) {
30
  return;
31
  }
32
 
51
  */
52
  public static function add_statistics_menu()
53
  {
54
+ if ( ! Sendgrid_Tools::check_username_password( Sendgrid_Tools::get_username(), Sendgrid_Tools::get_password() )
55
+ and ! Sendgrid_Tools::check_api_key( Sendgrid_Tools::get_api_key() ) ) {
56
  return;
57
  }
58
 
113
  }
114
 
115
  $parameters = array();
116
+
117
+ $parameters['api_user'] = Sendgrid_Tools::get_username();
118
+ $parameters['api_key'] = Sendgrid_Tools::get_password();
119
+ $parameters['apikey'] = Sendgrid_Tools::get_api_key();
120
+
121
  $parameters['data_type'] = 'global';
 
122
 
123
  if ( array_key_exists( 'days', $_POST ) ) {
124
  $parameters['days'] = $_POST['days'];
135
  }
136
  }
137
 
138
+ echo Sendgrid_Tools::curl_request( 'v3/stats', $parameters );
139
 
140
  die();
141
  }
lib/class-sendgrid-tools.php CHANGED
@@ -31,6 +31,36 @@ class Sendgrid_Tools
31
  return true;
32
  }
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  /**
35
  * Make cURL request to SendGrid API
36
  *
@@ -38,14 +68,30 @@ class Sendgrid_Tools
38
  * @param type $parameters
39
  * @return json
40
  */
41
- public static function curl_request( $api = 'api/stats.get.json', $parameters = array() )
42
  {
43
- $parameters['api_user'] = urlencode($parameters['api_user']);
44
- $parameters['api_key'] = urlencode($parameters['api_key']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  $data = urldecode( http_build_query( $parameters ) );
46
- $url = "https://sendgrid.com/$api?$data";
47
 
48
- $response = wp_remote_get( $url );
49
 
50
  if ( !is_array($response) or !isset( $response['body'] ) )
51
  {
@@ -83,6 +129,20 @@ class Sendgrid_Tools
83
  }
84
  }
85
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  /**
87
  * Return send method from the database or global variable
88
  *
@@ -99,6 +159,26 @@ class Sendgrid_Tools
99
  }
100
  }
101
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  /**
103
  * Return from name from the database or global variable
104
  *
31
  return true;
32
  }
33
 
34
+ /**
35
+ * Check api_key
36
+ *
37
+ * @param string $api_key sendgrid api_key
38
+ * @return bool
39
+ */
40
+ public static function check_api_key( $api_key )
41
+ {
42
+ $url = 'https://api.sendgrid.com/v3/user/profile';
43
+
44
+ $args = array(
45
+ 'headers' => array(
46
+ 'Authorization' => 'Bearer ' . $api_key )
47
+ );
48
+
49
+ $response = wp_remote_get( $url, $args );
50
+
51
+ if ( ! is_array( $response ) or ! isset( $response['body'] ) ) {
52
+ return false;
53
+ }
54
+
55
+ $response = json_decode( $response['body'], true );
56
+
57
+ if ( isset( $response['errors'] ) ) {
58
+ return false;
59
+ }
60
+
61
+ return true;
62
+ }
63
+
64
  /**
65
  * Make cURL request to SendGrid API
66
  *
68
  * @param type $parameters
69
  * @return json
70
  */
71
+ public static function curl_request( $api = 'v3/stats', $parameters = array() )
72
  {
73
+ $args = array();
74
+ if ( ! $parameters['apikey'] ) {
75
+ $creds = base64_encode($parameters['api_user'] . ':' . $parameters['api_key']);
76
+
77
+ $args = array(
78
+ 'headers' => array(
79
+ 'Authorization' => 'Basic ' . $creds
80
+ )
81
+ );
82
+
83
+ } else {
84
+ $args = array(
85
+ 'headers' => array(
86
+ 'Authorization' => 'Bearer ' . $parameters['apikey']
87
+ )
88
+ );
89
+ }
90
+
91
  $data = urldecode( http_build_query( $parameters ) );
92
+ $url = "https://api.sendgrid.com/$api?$data";
93
 
94
+ $response = wp_remote_get( $url, $args );
95
 
96
  if ( !is_array($response) or !isset( $response['body'] ) )
97
  {
129
  }
130
  }
131
 
132
+ /**
133
+ * Return api_key from the database or global variable
134
+ *
135
+ * @return string api key
136
+ */
137
+ public static function get_api_key()
138
+ {
139
+ if ( defined('SENDGRID_API_KEY') ) {
140
+ return SENDGRID_API_KEY;
141
+ } else {
142
+ return get_option('sendgrid_api_key');
143
+ }
144
+ }
145
+
146
  /**
147
  * Return send method from the database or global variable
148
  *
159
  }
160
  }
161
 
162
+ /**
163
+ * Return auth method from the database or global variable
164
+ *
165
+ * @return string auth_method
166
+ */
167
+ public static function get_auth_method()
168
+ {
169
+ if ( defined('SENDGRID_AUTH_METHOD') ) {
170
+ return SENDGRID_AUTH_METHOD;
171
+ } elseif ( Sendgrid_Tools::get_api_key() ) {
172
+ return 'apikey';
173
+ } elseif ( Sendgrid_Tools::get_username() and Sendgrid_Tools::get_password() and ! Sendgrid_Tools::get_api_key() ) {
174
+ return 'username';
175
+ } elseif ( get_option('sendgrid_auth_method') ) {
176
+ return get_option('sendgrid_auth_method');
177
+ } else {
178
+ return 'apikey';
179
+ }
180
+ }
181
+
182
  /**
183
  * Return from name from the database or global variable
184
  *
lib/overwrite-sendgrid-methods.php CHANGED
@@ -38,9 +38,17 @@ if ( ! function_exists('wp_mail'))
38
  */
39
  function wp_send( SendGrid\Email $email, $sendgrid )
40
  {
41
- $form = $email->toWebFormat();
42
- $form['api_user'] = Sendgrid_Tools::get_username();
43
- $form['api_key'] = Sendgrid_Tools::get_password();
 
 
 
 
 
 
 
 
44
 
45
  $url = $sendgrid->url . $sendgrid->endpoint;
46
 
@@ -65,18 +73,19 @@ if ( ! function_exists('wp_mail'))
65
  unset( $form[$value] );
66
  }
67
 
68
- $data = array(
69
- 'body' => $form
70
- );
71
-
72
  $response = wp_remote_post( $url, $data );
73
  }
74
  }
75
  else
76
  {
77
- $data = array(
78
- 'body' => $form
79
- );
 
80
 
81
  $response = wp_remote_post( $url, $data );
82
  }
@@ -121,11 +130,19 @@ if ( ! function_exists('wp_mail'))
121
  {
122
  if ( in_array( 'curl', get_loaded_extensions() ) )
123
  {
124
- $sendgrid = new SendGrid( Sendgrid_Tools::get_username(), Sendgrid_Tools::get_password() );
 
 
 
 
125
  }
126
  else
127
  {
128
- $sendgrid = new SendGridwp( Sendgrid_Tools::get_username(), Sendgrid_Tools::get_password() );
 
 
 
 
129
  }
130
  $mail = new SendGrid\Email();
131
 
@@ -405,7 +422,7 @@ if ( ! function_exists('wp_mail'))
405
  if ( class_exists('Swift') )
406
  {
407
  $smtp = new Smtp( Sendgrid_Tools::get_username(), Sendgrid_Tools::get_password() );
408
-
409
  return $smtp->send( $mail );
410
  }
411
  else
38
  */
39
  function wp_send( SendGrid\Email $email, $sendgrid )
40
  {
41
+ $form = $email->toWebFormat();
42
+ $headers = array();
43
+ $api_key = Sendgrid_Tools::get_api_key();
44
+ if ( ! $api_key ) {
45
+ $form['api_user'] = Sendgrid_Tools::get_username();
46
+ $form['api_key'] = Sendgrid_Tools::get_password();
47
+ } else {
48
+ $headers = array(
49
+ 'Authorization' => 'Bearer ' . $api_key
50
+ );
51
+ }
52
 
53
  $url = $sendgrid->url . $sendgrid->endpoint;
54
 
73
  unset( $form[$value] );
74
  }
75
 
76
+ $data = array('body' => $form);
77
+ if ( count( $headers ) ) {
78
+ $data['headers'] = $headers;
79
+ }
80
  $response = wp_remote_post( $url, $data );
81
  }
82
  }
83
  else
84
  {
85
+ $data = array('body' => $form);
86
+ if ( count( $headers ) ) {
87
+ $data['headers'] = $headers;
88
+ }
89
 
90
  $response = wp_remote_post( $url, $data );
91
  }
130
  {
131
  if ( in_array( 'curl', get_loaded_extensions() ) )
132
  {
133
+ if ( ! Sendgrid_Tools::get_api_key()) {
134
+ $sendgrid = new SendGrid( Sendgrid_Tools::get_username(), Sendgrid_Tools::get_password() );
135
+ } else {
136
+ $sendgrid = new SendGrid( Sendgrid_Tools::get_api_key() );
137
+ }
138
  }
139
  else
140
  {
141
+ if ( ! Sendgrid_Tools::get_api_key() ) {
142
+ $sendgrid = new SendGridwp( Sendgrid_Tools::get_username(), Sendgrid_Tools::get_password() );
143
+ } else {
144
+ $sendgrid = new SendGridwp( Sendgrid_Tools::get_api_key() );
145
+ }
146
  }
147
  $mail = new SendGrid\Email();
148
 
422
  if ( class_exists('Swift') )
423
  {
424
  $smtp = new Smtp( Sendgrid_Tools::get_username(), Sendgrid_Tools::get_password() );
425
+
426
  return $smtp->send( $mail );
427
  }
428
  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.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -114,14 +114,17 @@ Create a SendGrid account at <a href="http://sendgrid.com/partner/wordpress" tar
114
 
115
  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.
116
  2. After activation "Settings" link will appear.
117
- 3. Go to settings page and provide your SendGrid credentials. On this page you can set also the default "Name", "Sending Address" and "Reply Address".
118
- 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.
119
- 5. Header provided in the send test email form.
120
- 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.
121
- 7. Select the time interval for which you want to see SendGrid statistics and charts.
 
122
 
123
  == Changelog ==
124
 
 
 
125
  = 1.6.1 =
126
  * Add unique arguments
127
  = 1.6 =
@@ -173,6 +176,8 @@ Create a SendGrid account at <a href="http://sendgrid.com/partner/wordpress" tar
173
 
174
  == Upgrade notice ==
175
 
 
 
176
  = 1.6.1 =
177
  * Add unique arguments
178
  = 1.6 =
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.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
114
 
115
  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.
116
  2. After activation "Settings" link will appear.
117
+ 3. Go to settings page and provide your SendGrid credentials by choosing the authentication method which default is Api Key. On this page you can set also the default "Name", "Sending Address" and "Reply Address".
118
+ 4. If you want to use your username and password for authentication, switch to Username&Password authentication method.
119
+ 5. 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.
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.2 =
127
+ * Add Api Keys for authentication, use the last version of Sendgrid library: https://github.com/sendgrid/sendgrid-php/releases/tag/v3.2.0
128
  = 1.6.1 =
129
  * Add unique arguments
130
  = 1.6 =
176
 
177
  == Upgrade notice ==
178
 
179
+ = 1.6.2 =
180
+ * Add Api Keys for authentication, use the last version of Sendgrid library: https://github.com/sendgrid/sendgrid-php/releases/tag/v3.2.0
181
  = 1.6.1 =
182
  * Add unique arguments
183
  = 1.6 =
vendor/sendgrid-php/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
  All notable changes to this project will be documented in this file.
3
  This project adheres to [Semantic Versioning](http://semver.org/).
4
 
 
 
 
 
 
 
 
 
 
5
  ## [v3.0.0] - (2015-04-14)
6
  ### Fixed
7
  - CC and BCC not working with SMTPAPI To
2
  All notable changes to this project will be documented in this file.
3
  This project adheres to [Semantic Versioning](http://semver.org/).
4
 
5
+ ## [v3.2.0] - (2015-05-13)
6
+ ### Added
7
+ - Specify Guzzle proxy via [#149](https://github.com/sendgrid/sendgrid-php/pull/149)
8
+ - Option to disable exception raising
9
+
10
+ ## [v3.1.0] - (2015-04-27)
11
+ ### Added
12
+ - Support for API keys
13
+
14
  ## [v3.0.0] - (2015-04-14)
15
  ### Fixed
16
  - CC and BCC not working with SMTPAPI To
vendor/sendgrid-php/README.md CHANGED
@@ -12,7 +12,7 @@ One of the most notable changes is how `addTo()` behaves. We are now using our W
12
 
13
  Smtpapi addressing methods cannot be mixed with non Smtpapi addressing methods. Meaning you cannot currently use Cc and Bcc with `addSmtpapiTo()`.
14
 
15
- The `send()` method now raises a `\SendGrid\Exception` if the response code is not 200 and returns an instance of `\SendGrid\Response`.
16
 
17
  ---
18
 
@@ -53,7 +53,7 @@ Add SendGrid to your `composer.json` file. If you are not using [Composer](http:
53
  ```json
54
  {
55
  "require": {
56
- "sendgrid/sendgrid": "~3.0"
57
  }
58
  }
59
  ```
@@ -84,10 +84,12 @@ There is a [sendgrid-php-example app](https://github.com/sendgrid/sendgrid-php-e
84
 
85
  ## Usage
86
 
87
- To begin using this library, initialize the SendGrid object with your SendGrid credentials.
88
 
89
  ```php
90
  $sendgrid = new SendGrid('username', 'password');
 
 
91
  ```
92
 
93
  Create a new SendGrid Email object and add your message details.
@@ -109,6 +111,17 @@ Send it.
109
  ```php
110
  $sendgrid->send($email);
111
  ```
 
 
 
 
 
 
 
 
 
 
 
112
  ### Options
113
  Options may be passed to the library when initializing the SendGrid object:
114
 
@@ -120,6 +133,7 @@ $options = array(
120
  'endpoint' => '/api/mail.send.json',
121
  'port' => null,
122
  'url' => null,
 
123
  );
124
  $sendgrid = new SendGrid('username', 'password', $options);
125
  ```
@@ -331,8 +345,6 @@ $email = new SendGrid\Email();
331
  $email
332
  ->setFrom('foo@bar.com')
333
  ->setFromName('Foo Bar')
334
- ->setFrom('other@example.com')
335
- ->setFromName('Other Guy')
336
  ;
337
  $sendgrid->send($email);
338
  ```
@@ -601,7 +613,7 @@ $email = new SendGrid\Email();
601
  $email
602
  ->addTo('foo@bar.com')
603
  ->setHtml('<div>Our logo:<img src="cid:file-cid"></div>')
604
- ->addAttachment("../path/to/file.txt", "super_file.txt", "file-cid")
605
  ;
606
  ```
607
 
12
 
13
  Smtpapi addressing methods cannot be mixed with non Smtpapi addressing methods. Meaning you cannot currently use Cc and Bcc with `addSmtpapiTo()`.
14
 
15
+ The `send()` method now raises a `\SendGrid\Exception` by default if the response code is not 200 and returns an instance of `\SendGrid\Response`.
16
 
17
  ---
18
 
53
  ```json
54
  {
55
  "require": {
56
+ "sendgrid/sendgrid": "~3.2"
57
  }
58
  }
59
  ```
84
 
85
  ## Usage
86
 
87
+ To begin using this library, initialize the SendGrid object with your SendGrid credentials OR a SendGrid [API Key](https://sendgrid.com/docs/User_Guide/Account/api_keys.html). API Key is the preferred method. API Keys are in beta. To configure API keys, visit https://sendgrid.com/beta/settings/api_key.
88
 
89
  ```php
90
  $sendgrid = new SendGrid('username', 'password');
91
+ // OR
92
+ $sendgrid = new SendGrid('sendgrid api key');
93
  ```
94
 
95
  Create a new SendGrid Email object and add your message details.
111
  ```php
112
  $sendgrid->send($email);
113
  ```
114
+
115
+ ### Exceptions
116
+
117
+ A `SendGrid\Exception` is raised by default if the response is not 200 OK.
118
+
119
+ To disable exceptions, pass in the `raise_exceptions => false` option when creating a `SendGrid\Client`.
120
+
121
+ ```php
122
+ $client = new SendGrid('SENDGRID_APIKEY', array('raise_exceptions' => false));
123
+ ```
124
+
125
  ### Options
126
  Options may be passed to the library when initializing the SendGrid object:
127
 
133
  'endpoint' => '/api/mail.send.json',
134
  'port' => null,
135
  'url' => null,
136
+ 'raise_exceptions' => false
137
  );
138
  $sendgrid = new SendGrid('username', 'password', $options);
139
  ```
345
  $email
346
  ->setFrom('foo@bar.com')
347
  ->setFromName('Foo Bar')
 
 
348
  ;
349
  $sendgrid->send($email);
350
  ```
613
  $email
614
  ->addTo('foo@bar.com')
615
  ->setHtml('<div>Our logo:<img src="cid:file-cid"></div>')
616
+ ->addAttachment("../path/to/file.png", "super_file.png", "file-cid")
617
  ;
618
  ```
619
 
vendor/sendgrid-php/composer.lock CHANGED
@@ -4,7 +4,7 @@
4
  "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
5
  "This file is @generated automatically"
6
  ],
7
- "hash": "f7fedb7a545e4e6692a28421a438785b",
8
  "packages": [
9
  {
10
  "name": "guzzle/guzzle",
@@ -151,21 +151,20 @@
151
  },
152
  {
153
  "name": "symfony/event-dispatcher",
154
- "version": "v2.6.6",
155
- "target-dir": "Symfony/Component/EventDispatcher",
156
  "source": {
157
  "type": "git",
158
  "url": "https://github.com/symfony/EventDispatcher.git",
159
- "reference": "70f7c8478739ad21e3deef0d977b38c77f1fb284"
160
  },
161
  "dist": {
162
  "type": "zip",
163
- "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/70f7c8478739ad21e3deef0d977b38c77f1fb284",
164
- "reference": "70f7c8478739ad21e3deef0d977b38c77f1fb284",
165
  "shasum": ""
166
  },
167
  "require": {
168
- "php": ">=5.3.3"
169
  },
170
  "require-dev": {
171
  "psr/log": "~1.0",
@@ -182,11 +181,11 @@
182
  "type": "library",
183
  "extra": {
184
  "branch-alias": {
185
- "dev-master": "2.6-dev"
186
  }
187
  },
188
  "autoload": {
189
- "psr-0": {
190
  "Symfony\\Component\\EventDispatcher\\": ""
191
  }
192
  },
@@ -195,18 +194,18 @@
195
  "MIT"
196
  ],
197
  "authors": [
198
- {
199
- "name": "Symfony Community",
200
- "homepage": "http://symfony.com/contributors"
201
- },
202
  {
203
  "name": "Fabien Potencier",
204
  "email": "fabien@symfony.com"
 
 
 
 
205
  }
206
  ],
207
  "description": "Symfony EventDispatcher Component",
208
- "homepage": "http://symfony.com",
209
- "time": "2015-03-13 17:37:22"
210
  }
211
  ],
212
  "packages-dev": null,
4
  "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
5
  "This file is @generated automatically"
6
  ],
7
+ "hash": "b6c3cc0d302a93c45e7de2544e6d5b76",
8
  "packages": [
9
  {
10
  "name": "guzzle/guzzle",
151
  },
152
  {
153
  "name": "symfony/event-dispatcher",
154
+ "version": "v2.7.1",
 
155
  "source": {
156
  "type": "git",
157
  "url": "https://github.com/symfony/EventDispatcher.git",
158
+ "reference": "be3c5ff8d503c46768aeb78ce6333051aa6f26d9"
159
  },
160
  "dist": {
161
  "type": "zip",
162
+ "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/be3c5ff8d503c46768aeb78ce6333051aa6f26d9",
163
+ "reference": "be3c5ff8d503c46768aeb78ce6333051aa6f26d9",
164
  "shasum": ""
165
  },
166
  "require": {
167
+ "php": ">=5.3.9"
168
  },
169
  "require-dev": {
170
  "psr/log": "~1.0",
181
  "type": "library",
182
  "extra": {
183
  "branch-alias": {
184
+ "dev-master": "2.7-dev"
185
  }
186
  },
187
  "autoload": {
188
+ "psr-4": {
189
  "Symfony\\Component\\EventDispatcher\\": ""
190
  }
191
  },
194
  "MIT"
195
  ],
196
  "authors": [
 
 
 
 
197
  {
198
  "name": "Fabien Potencier",
199
  "email": "fabien@symfony.com"
200
+ },
201
+ {
202
+ "name": "Symfony Community",
203
+ "homepage": "https://symfony.com/contributors"
204
  }
205
  ],
206
  "description": "Symfony EventDispatcher Component",
207
+ "homepage": "https://symfony.com",
208
+ "time": "2015-06-08 09:37:21"
209
  }
210
  ],
211
  "packages-dev": null,
vendor/sendgrid-php/lib/SendGrid.php CHANGED
@@ -2,11 +2,11 @@
2
 
3
  class SendGrid
4
  {
5
- const VERSION = '3.0.0';
6
 
7
  protected
8
- $namespace = 'SendGrid',
9
- $headers = array('Content-Type' => 'application/json'),
10
  $client,
11
  $options;
12
 
@@ -15,29 +15,72 @@ class SendGrid
15
  $apiKey,
16
  $url,
17
  $endpoint,
18
- $version = self::VERSION;
19
 
20
- public function __construct($apiUser, $apiKey, $options = array())
21
  {
22
- $this->apiUser = $apiUser;
23
- $this->apiKey = $apiKey;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
- $options['turn_off_ssl_verification'] = (isset($options['turn_off_ssl_verification']) && $options['turn_off_ssl_verification'] == true);
26
- $protocol = isset($options['protocol']) ? $options['protocol'] : 'https';
27
- $host = isset($options['host']) ? $options['host'] : 'api.sendgrid.com';
28
- $port = isset($options['port']) ? $options['port'] : '';
29
- $this->options = $options;
30
 
31
- $this->url = isset($options['url']) ? $options['url'] : $protocol . '://' . $host . ($port ? ':' . $port : '');
32
- $this->endpoint = isset($options['endpoint']) ? $options['endpoint'] : '/api/mail.send.json';
33
 
34
- $this->client = new \Guzzle\Http\Client($this->url, array(
 
 
 
 
 
 
 
35
  'request.options' => array(
36
  'verify' => !$this->options['turn_off_ssl_verification'],
37
- 'exceptions' => false // FIXME: This might not be wise but we don't want guzzle throwing
38
  )
39
- ));
40
- $this->client->setUserAgent('sendgrid/' . $this->version . ';php');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  }
42
 
43
  /**
@@ -50,19 +93,25 @@ class SendGrid
50
 
51
  /**
52
  * Makes a post request to SendGrid to send an email
 
53
  * @param SendGrid\Email $email Email object built
 
54
  * @throws SendGrid\Exception if the response code is not 200
55
  * @return stdClass SendGrid response object
56
  */
57
  public function send(SendGrid\Email $email)
58
  {
59
- $form = $email->toWebFormat();
60
- $form['api_user'] = $this->apiUser;
61
- $form['api_key'] = $this->apiKey;
 
 
 
 
62
 
63
  $response = $this->postRequest($this->endpoint, $form);
64
 
65
- if ($response->code != 200) {
66
  throw new SendGrid\Exception($response->raw_body, $response->code);
67
  }
68
 
@@ -71,8 +120,10 @@ class SendGrid
71
 
72
  /**
73
  * Makes the actual HTTP request to SendGrid
 
74
  * @param $endpoint string endpoint to post to
75
  * @param $form array web ready version of SendGrid\Email
 
76
  * @return SendGrid\Response
77
  */
78
  public function postRequest($endpoint, $form)
2
 
3
  class SendGrid
4
  {
5
+ const VERSION = '3.2.0';
6
 
7
  protected
8
+ $namespace = 'SendGrid',
9
+ $headers = array('Content-Type' => 'application/json'),
10
  $client,
11
  $options;
12
 
15
  $apiKey,
16
  $url,
17
  $endpoint,
18
+ $version = self::VERSION;
19
 
20
+ public function __construct($apiUserOrKey, $apiKeyOrOptions = null, $options = array())
21
  {
22
+ // Check if given a username + password or api key
23
+ if (is_string($apiKeyOrOptions)) {
24
+ // Username and password
25
+ $this->apiUser = $apiUserOrKey;
26
+ $this->apiKey = $apiKeyOrOptions;
27
+ $this->options = $options;
28
+ } elseif (is_array($apiKeyOrOptions) || $apiKeyOrOptions === null) {
29
+ // API key
30
+ $this->apiKey = $apiUserOrKey;
31
+ $this->apiUser = null;
32
+
33
+ // With options
34
+ if (is_array($apiKeyOrOptions)) {
35
+ $this->options = $apiKeyOrOptions;
36
+ }
37
+ } else {
38
+ // Won't be thrown?
39
+ throw new InvalidArgumentException('Need a username + password or api key!');
40
+ }
41
+
42
+ $this->options['turn_off_ssl_verification'] = (isset($this->options['turn_off_ssl_verification']) && $this->options['turn_off_ssl_verification'] == true);
43
+ if (!isset($this->options['raise_exceptions'])) {
44
+ $this->options['raise_exceptions'] = true;
45
+ }
46
+ $protocol = isset($this->options['protocol']) ? $this->options['protocol'] : 'https';
47
+ $host = isset($this->options['host']) ? $this->options['host'] : 'api.sendgrid.com';
48
+ $port = isset($this->options['port']) ? $this->options['port'] : '';
49
 
50
+ $this->url = isset($this->options['url']) ? $this->options['url'] : $protocol . '://' . $host . ($port ? ':' . $port : '');
51
+ $this->endpoint = isset($this->options['endpoint']) ? $this->options['endpoint'] : '/api/mail.send.json';
 
 
 
52
 
53
+ $this->client = $this->prepareHttpClient();
54
+ }
55
 
56
+ /**
57
+ * Prepares the HTTP client
58
+ *
59
+ * @return \Guzzle\Http\Client
60
+ */
61
+ private function prepareHttpClient()
62
+ {
63
+ $guzzleOption = array(
64
  'request.options' => array(
65
  'verify' => !$this->options['turn_off_ssl_verification'],
66
+ 'exceptions' => (isset($this->options['enable_guzzle_exceptions']) && $this->options['enable_guzzle_exceptions'] == true)
67
  )
68
+ );
69
+
70
+ // Using api key
71
+ if ($this->apiUser === null) {
72
+ $guzzleOption['request.options']['headers'] = array('Authorization' => 'Bearer ' . $this->apiKey);
73
+ }
74
+
75
+ // Using http proxy
76
+ if (isset($this->options['proxy'])) {
77
+ $guzzleOption['request.options']['proxy'] = $this->options['proxy'];
78
+ }
79
+
80
+ $client = new \Guzzle\Http\Client($this->url, $guzzleOption);
81
+ $client->setUserAgent('sendgrid/' . $this->version . ';php');
82
+
83
+ return $client;
84
  }
85
 
86
  /**
93
 
94
  /**
95
  * Makes a post request to SendGrid to send an email
96
+ *
97
  * @param SendGrid\Email $email Email object built
98
+ *
99
  * @throws SendGrid\Exception if the response code is not 200
100
  * @return stdClass SendGrid response object
101
  */
102
  public function send(SendGrid\Email $email)
103
  {
104
+ $form = $email->toWebFormat();
105
+
106
+ // Using username password
107
+ if ($this->apiUser !== null) {
108
+ $form['api_user'] = $this->apiUser;
109
+ $form['api_key'] = $this->apiKey;
110
+ }
111
 
112
  $response = $this->postRequest($this->endpoint, $form);
113
 
114
+ if ($response->code != 200 && $this->options['raise_exceptions']) {
115
  throw new SendGrid\Exception($response->raw_body, $response->code);
116
  }
117
 
120
 
121
  /**
122
  * Makes the actual HTTP request to SendGrid
123
+ *
124
  * @param $endpoint string endpoint to post to
125
  * @param $form array web ready version of SendGrid\Email
126
+ *
127
  * @return SendGrid\Response
128
  */
129
  public function postRequest($endpoint, $form)
vendor/sendgrid-php/lib/SendGrid/Email.php CHANGED
@@ -25,23 +25,24 @@ class Email
25
 
26
  public function __construct()
27
  {
28
- $this->fromName = false;
29
- $this->replyTo = false;
30
- $this->smtpapi = new \Smtpapi\Header();
31
  }
32
 
33
  /**
34
  * _removeFromList
35
  * Given a list of key/value pairs, removes the associated keys
36
  * where a value matches the given string ($item)
 
37
  * @param Array $list - the list of key/value pairs
38
  * @param String $item - the value to be removed
39
  */
40
  private function _removeFromList(&$list, $item, $key_field = null)
41
  {
42
  foreach ($list as $key => $val) {
43
- if($key_field) {
44
- if($val[$key_field] == $item) {
45
  unset($list[$key]);
46
  }
47
  } else {
@@ -82,18 +83,21 @@ class Email
82
  public function addSmtpapiTo($email, $name = null)
83
  {
84
  $this->smtpapi->addTo($email, $name);
 
85
  return $this;
86
  }
87
 
88
  public function setTos(array $emails)
89
  {
90
  $this->to = $emails;
 
91
  return $this;
92
  }
93
 
94
  public function setSmtpapiTos(array $emails)
95
  {
96
  $this->smtpapi->setTos($emails);
 
97
  return $this;
98
  }
99
 
@@ -104,6 +108,7 @@ class Email
104
  }
105
 
106
  $this->toName[] = $name;
 
107
  return $this;
108
  }
109
 
@@ -115,12 +120,13 @@ class Email
115
  public function setFrom($email)
116
  {
117
  $this->from = $email;
 
118
  return $this;
119
  }
120
 
121
  public function getFrom($as_array = false)
122
  {
123
- if($as_array && ($name = $this->getFromName())) {
124
  return array("$this->from" => $name);
125
  } else {
126
  return $this->from;
@@ -130,6 +136,7 @@ class Email
130
  public function setFromName($name)
131
  {
132
  $this->fromName = $name;
 
133
  return $this;
134
  }
135
 
@@ -141,6 +148,7 @@ class Email
141
  public function setReplyTo($email)
142
  {
143
  $this->replyTo = $email;
 
144
  return $this;
145
  }
146
 
@@ -152,12 +160,14 @@ class Email
152
  public function setCc($email)
153
  {
154
  $this->cc = array($email);
 
155
  return $this;
156
  }
157
 
158
  public function setCcs(array $email_list)
159
  {
160
  $this->cc = $email_list;
 
161
  return $this;
162
  }
163
 
@@ -193,6 +203,7 @@ class Email
193
  }
194
 
195
  $this->ccName[] = $name;
 
196
  return $this;
197
  }
198
 
@@ -216,12 +227,14 @@ class Email
216
  public function setBcc($email)
217
  {
218
  $this->bcc = array($email);
 
219
  return $this;
220
  }
221
 
222
  public function setBccs($email_list)
223
  {
224
  $this->bcc = $email_list;
 
225
  return $this;
226
  }
227
 
@@ -257,6 +270,7 @@ class Email
257
  }
258
 
259
  $this->bccName[] = $name;
 
260
  return $this;
261
  }
262
 
@@ -268,6 +282,7 @@ class Email
268
  public function removeBcc($email)
269
  {
270
  $this->_removeFromList($this->bcc, $email);
 
271
  return $this;
272
  }
273
 
@@ -279,6 +294,7 @@ class Email
279
  public function setSubject($subject)
280
  {
281
  $this->subject = $subject;
 
282
  return $this;
283
  }
284
 
@@ -290,6 +306,7 @@ class Email
290
  public function setDate($date)
291
  {
292
  $this->date = $date;
 
293
  return $this;
294
  }
295
 
@@ -301,6 +318,7 @@ class Email
301
  public function setText($text)
302
  {
303
  $this->text = $text;
 
304
  return $this;
305
  }
306
 
@@ -312,6 +330,7 @@ class Email
312
  public function setHtml($html)
313
  {
314
  $this->html = $html;
 
315
  return $this;
316
  }
317
 
@@ -323,40 +342,49 @@ class Email
323
  public function setSendAt($timestamp)
324
  {
325
  $this->smtpapi->setSendAt($timestamp);
 
326
  return $this;
327
  }
328
 
329
  public function setSendEachAt(array $timestamps)
330
  {
331
  $this->smtpapi->setSendEachAt($timestamps);
 
332
  return $this;
333
  }
334
 
335
  public function addSendEachAt($timestamp)
336
  {
337
  $this->smtpapi->addSendEachAt($timestamp);
 
338
  return $this;
339
  }
340
 
341
  /**
342
  * Convenience method to add template
 
343
  * @param string The id of the template
 
344
  * @return $this
345
  */
346
  public function setTemplateId($templateId)
347
  {
348
  $this->addFilter('templates', 'enabled', 1);
349
  $this->addFilter('templates', 'template_id', $templateId);
 
350
  return $this;
351
  }
352
 
353
  /** Convenience method to set asm group id
 
354
  * @param string the group id
 
355
  * @return $this
356
  */
357
  public function setAsmGroupId($groupId)
358
  {
359
  $this->smtpapi->setASMGroupID($groupId);
 
360
  return $this;
361
  }
362
 
@@ -364,7 +392,7 @@ class Email
364
  {
365
  $this->attachments = array();
366
 
367
- foreach($files as $filename => $file) {
368
  if (is_string($filename)) {
369
  $this->addAttachment($file, $filename);
370
  } else {
@@ -378,12 +406,14 @@ class Email
378
  public function setAttachment($file, $custom_filename = null, $cid = null)
379
  {
380
  $this->attachments = array($this->getAttachmentInfo($file, $custom_filename, $cid));
 
381
  return $this;
382
  }
383
 
384
  public function addAttachment($file, $custom_filename = null, $cid = null)
385
  {
386
  $this->attachments[] = $this->getAttachmentInfo($file, $custom_filename, $cid);
 
387
  return $this;
388
  }
389
 
@@ -395,6 +425,7 @@ class Email
395
  public function removeAttachment($file)
396
  {
397
  $this->_removeFromList($this->attachments, $file, "file");
 
398
  return $this;
399
  }
400
 
@@ -403,7 +434,7 @@ class Email
403
  $info = pathinfo($file);
404
  $info['file'] = $file;
405
  if (!is_null($custom_filename)) {
406
- $info['custom_filename'] = $custom_filename;
407
  }
408
  if ($cid !== null) {
409
  $info['cid'] = $cid;
@@ -415,54 +446,63 @@ class Email
415
  public function setCategories($categories)
416
  {
417
  $this->smtpapi->setCategories($categories);
 
418
  return $this;
419
  }
420
 
421
  public function setCategory($category)
422
  {
423
  $this->smtpapi->setCategory($category);
 
424
  return $this;
425
  }
426
 
427
  public function addCategory($category)
428
  {
429
  $this->smtpapi->addCategory($category);
 
430
  return $this;
431
  }
432
 
433
  public function removeCategory($category)
434
  {
435
  $this->smtpapi->removeCategory($category);
 
436
  return $this;
437
  }
438
 
439
  public function setSubstitutions($key_value_pairs)
440
  {
441
  $this->smtpapi->setSubstitutions($key_value_pairs);
 
442
  return $this;
443
  }
444
 
445
  public function addSubstitution($from_value, array $to_values)
446
  {
447
  $this->smtpapi->addSubstitution($from_value, $to_values);
 
448
  return $this;
449
  }
450
 
451
  public function setSections(array $key_value_pairs)
452
  {
453
  $this->smtpapi->setSections($key_value_pairs);
 
454
  return $this;
455
  }
456
 
457
  public function addSection($from_value, $to_value)
458
  {
459
  $this->smtpapi->addSection($from_value, $to_value);
 
460
  return $this;
461
  }
462
 
463
  public function setUniqueArgs(array $key_value_pairs)
464
  {
465
  $this->smtpapi->setUniqueArgs($key_value_pairs);
 
466
  return $this;
467
  }
468
 
@@ -470,12 +510,14 @@ class Email
470
  public function setUniqueArguments(array $key_value_pairs)
471
  {
472
  $this->smtpapi->setUniqueArgs($key_value_pairs);
 
473
  return $this;
474
  }
475
 
476
  public function addUniqueArg($key, $value)
477
  {
478
  $this->smtpapi->addUniqueArg($key, $value);
 
479
  return $this;
480
  }
481
 
@@ -483,12 +525,14 @@ class Email
483
  public function addUniqueArgument($key, $value)
484
  {
485
  $this->smtpapi->addUniqueArg($key, $value);
 
486
  return $this;
487
  }
488
 
489
  public function setFilters($filter_settings)
490
  {
491
  $this->smtpapi->setFilters($filter_settings);
 
492
  return $this;
493
  }
494
 
@@ -496,12 +540,14 @@ class Email
496
  public function setFilterSettings($filter_settings)
497
  {
498
  $this->smtpapi->setFilters($filter_settings);
 
499
  return $this;
500
  }
501
 
502
  public function addFilter($filter_name, $parameter_name, $parameter_value)
503
  {
504
  $this->smtpapi->addFilter($filter_name, $parameter_name, $parameter_value);
 
505
  return $this;
506
  }
507
 
@@ -509,6 +555,7 @@ class Email
509
  public function addFilterSetting($filter_name, $parameter_name, $parameter_value)
510
  {
511
  $this->smtpapi->addFilter($filter_name, $parameter_name, $parameter_value);
 
512
  return $this;
513
  }
514
 
@@ -522,24 +569,28 @@ class Email
522
  if (count($this->getHeaders()) <= 0) {
523
  return "{}";
524
  }
 
525
  return json_encode($this->getHeaders(), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
526
  }
527
 
528
  public function setHeaders($key_value_pairs)
529
  {
530
  $this->headers = $key_value_pairs;
 
531
  return $this;
532
  }
533
 
534
  public function addHeader($key, $value)
535
  {
536
  $this->headers[$key] = $value;
 
537
  return $this;
538
  }
539
 
540
  public function removeHeader($key)
541
  {
542
  unset($this->headers[$key]);
 
543
  return $this;
544
  }
545
 
@@ -551,49 +602,67 @@ class Email
551
  public function toWebFormat()
552
  {
553
  $web = array(
554
- 'to' => $this->to,
555
- 'from' => $this->getFrom(),
556
- 'x-smtpapi' => $this->smtpapi->jsonString(),
557
- 'subject' => $this->getSubject(),
558
- 'text' => $this->getText(),
559
- 'html' => $this->getHtml(),
560
- 'headers' => $this->getHeadersJson(),
561
  );
562
 
563
- if ($this->getToNames()) { $web['toname'] = $this->getToNames(); }
564
- if ($this->getCcs()) { $web['cc'] = $this->getCcs(); }
565
- if ($this->getCcNames()) { $web['ccname'] = $this->getCcNames(); }
566
- if ($this->getBccs()) { $web['bcc'] = $this->getBccs(); }
567
- if ($this->getBccNames()) { $web['bccname'] = $this->getBccNames(); }
568
- if ($this->getFromName()) { $web['fromname'] = $this->getFromName(); }
569
- if ($this->getReplyTo()) { $web['replyto'] = $this->getReplyTo(); }
570
- if ($this->getDate()) { $web['date'] = $this->getDate(); }
571
- if ($this->smtpapi->to && (count($this->smtpapi->to) > 0)) { $web['to'] = ""; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
572
 
573
  $web = $this->updateMissingTo($web);
574
 
575
  if ($this->getAttachments()) {
576
- foreach($this->getAttachments() as $f) {
577
- $file = $f['file'];
578
- $extension = null;
579
  if (array_key_exists('extension', $f)) {
580
- $extension = $f['extension'];
581
  };
582
- $filename = $f['filename'];
583
- $full_filename = $filename;
584
 
585
  if (isset($extension)) {
586
- $full_filename = $filename.'.'.$extension;
587
  }
588
  if (array_key_exists('custom_filename', $f)) {
589
- $full_filename = $f['custom_filename'];
590
  }
591
 
592
  if (array_key_exists('cid', $f)) {
593
- $web['content['.$full_filename.']'] = $f['cid'];
594
  }
595
 
596
- $contents = '@' . $file;
597
 
598
  // Guzzle handles this for us.
599
  // http://guzzle3.readthedocs.org/en/latest/http-client/request.html#post-requests
@@ -601,7 +670,7 @@ class Email
601
  // $contents = new \CurlFile($file, $extension, $filename);
602
  // }
603
 
604
- $web['files['.$full_filename.']'] = $contents;
605
  };
606
  }
607
 
@@ -617,6 +686,7 @@ class Email
617
  if ($this->smtpapi->to && (count($this->smtpapi->to) > 0)) {
618
  $data['to'] = $this->getFrom();
619
  }
 
620
  return $data;
621
  }
622
  }
25
 
26
  public function __construct()
27
  {
28
+ $this->fromName = false;
29
+ $this->replyTo = false;
30
+ $this->smtpapi = new \Smtpapi\Header();
31
  }
32
 
33
  /**
34
  * _removeFromList
35
  * Given a list of key/value pairs, removes the associated keys
36
  * where a value matches the given string ($item)
37
+ *
38
  * @param Array $list - the list of key/value pairs
39
  * @param String $item - the value to be removed
40
  */
41
  private function _removeFromList(&$list, $item, $key_field = null)
42
  {
43
  foreach ($list as $key => $val) {
44
+ if ($key_field) {
45
+ if ($val[$key_field] == $item) {
46
  unset($list[$key]);
47
  }
48
  } else {
83
  public function addSmtpapiTo($email, $name = null)
84
  {
85
  $this->smtpapi->addTo($email, $name);
86
+
87
  return $this;
88
  }
89
 
90
  public function setTos(array $emails)
91
  {
92
  $this->to = $emails;
93
+
94
  return $this;
95
  }
96
 
97
  public function setSmtpapiTos(array $emails)
98
  {
99
  $this->smtpapi->setTos($emails);
100
+
101
  return $this;
102
  }
103
 
108
  }
109
 
110
  $this->toName[] = $name;
111
+
112
  return $this;
113
  }
114
 
120
  public function setFrom($email)
121
  {
122
  $this->from = $email;
123
+
124
  return $this;
125
  }
126
 
127
  public function getFrom($as_array = false)
128
  {
129
+ if ($as_array && ($name = $this->getFromName())) {
130
  return array("$this->from" => $name);
131
  } else {
132
  return $this->from;
136
  public function setFromName($name)
137
  {
138
  $this->fromName = $name;
139
+
140
  return $this;
141
  }
142
 
148
  public function setReplyTo($email)
149
  {
150
  $this->replyTo = $email;
151
+
152
  return $this;
153
  }
154
 
160
  public function setCc($email)
161
  {
162
  $this->cc = array($email);
163
+
164
  return $this;
165
  }
166
 
167
  public function setCcs(array $email_list)
168
  {
169
  $this->cc = $email_list;
170
+
171
  return $this;
172
  }
173
 
203
  }
204
 
205
  $this->ccName[] = $name;
206
+
207
  return $this;
208
  }
209
 
227
  public function setBcc($email)
228
  {
229
  $this->bcc = array($email);
230
+
231
  return $this;
232
  }
233
 
234
  public function setBccs($email_list)
235
  {
236
  $this->bcc = $email_list;
237
+
238
  return $this;
239
  }
240
 
270
  }
271
 
272
  $this->bccName[] = $name;
273
+
274
  return $this;
275
  }
276
 
282
  public function removeBcc($email)
283
  {
284
  $this->_removeFromList($this->bcc, $email);
285
+
286
  return $this;
287
  }
288
 
294
  public function setSubject($subject)
295
  {
296
  $this->subject = $subject;
297
+
298
  return $this;
299
  }
300
 
306
  public function setDate($date)
307
  {
308
  $this->date = $date;
309
+
310
  return $this;
311
  }
312
 
318
  public function setText($text)
319
  {
320
  $this->text = $text;
321
+
322
  return $this;
323
  }
324
 
330
  public function setHtml($html)
331
  {
332
  $this->html = $html;
333
+
334
  return $this;
335
  }
336
 
342
  public function setSendAt($timestamp)
343
  {
344
  $this->smtpapi->setSendAt($timestamp);
345
+
346
  return $this;
347
  }
348
 
349
  public function setSendEachAt(array $timestamps)
350
  {
351
  $this->smtpapi->setSendEachAt($timestamps);
352
+
353
  return $this;
354
  }
355
 
356
  public function addSendEachAt($timestamp)
357
  {
358
  $this->smtpapi->addSendEachAt($timestamp);
359
+
360
  return $this;
361
  }
362
 
363
  /**
364
  * Convenience method to add template
365
+ *
366
  * @param string The id of the template
367
+ *
368
  * @return $this
369
  */
370
  public function setTemplateId($templateId)
371
  {
372
  $this->addFilter('templates', 'enabled', 1);
373
  $this->addFilter('templates', 'template_id', $templateId);
374
+
375
  return $this;
376
  }
377
 
378
  /** Convenience method to set asm group id
379
+ *
380
  * @param string the group id
381
+ *
382
  * @return $this
383
  */
384
  public function setAsmGroupId($groupId)
385
  {
386
  $this->smtpapi->setASMGroupID($groupId);
387
+
388
  return $this;
389
  }
390
 
392
  {
393
  $this->attachments = array();
394
 
395
+ foreach ($files as $filename => $file) {
396
  if (is_string($filename)) {
397
  $this->addAttachment($file, $filename);
398
  } else {
406
  public function setAttachment($file, $custom_filename = null, $cid = null)
407
  {
408
  $this->attachments = array($this->getAttachmentInfo($file, $custom_filename, $cid));
409
+
410
  return $this;
411
  }
412
 
413
  public function addAttachment($file, $custom_filename = null, $cid = null)
414
  {
415
  $this->attachments[] = $this->getAttachmentInfo($file, $custom_filename, $cid);
416
+
417
  return $this;
418
  }
419
 
425
  public function removeAttachment($file)
426
  {
427
  $this->_removeFromList($this->attachments, $file, "file");
428
+
429
  return $this;
430
  }
431
 
434
  $info = pathinfo($file);
435
  $info['file'] = $file;
436
  if (!is_null($custom_filename)) {
437
+ $info['custom_filename'] = $custom_filename;
438
  }
439
  if ($cid !== null) {
440
  $info['cid'] = $cid;
446
  public function setCategories($categories)
447
  {
448
  $this->smtpapi->setCategories($categories);
449
+
450
  return $this;
451
  }
452
 
453
  public function setCategory($category)
454
  {
455
  $this->smtpapi->setCategory($category);
456
+
457
  return $this;
458
  }
459
 
460
  public function addCategory($category)
461
  {
462
  $this->smtpapi->addCategory($category);
463
+
464
  return $this;
465
  }
466
 
467
  public function removeCategory($category)
468
  {
469
  $this->smtpapi->removeCategory($category);
470
+
471
  return $this;
472
  }
473
 
474
  public function setSubstitutions($key_value_pairs)
475
  {
476
  $this->smtpapi->setSubstitutions($key_value_pairs);
477
+
478
  return $this;
479
  }
480
 
481
  public function addSubstitution($from_value, array $to_values)
482
  {
483
  $this->smtpapi->addSubstitution($from_value, $to_values);
484
+
485
  return $this;
486
  }
487
 
488
  public function setSections(array $key_value_pairs)
489
  {
490
  $this->smtpapi->setSections($key_value_pairs);
491
+
492
  return $this;
493
  }
494
 
495
  public function addSection($from_value, $to_value)
496
  {
497
  $this->smtpapi->addSection($from_value, $to_value);
498
+
499
  return $this;
500
  }
501
 
502
  public function setUniqueArgs(array $key_value_pairs)
503
  {
504
  $this->smtpapi->setUniqueArgs($key_value_pairs);
505
+
506
  return $this;
507
  }
508
 
510
  public function setUniqueArguments(array $key_value_pairs)
511
  {
512
  $this->smtpapi->setUniqueArgs($key_value_pairs);
513
+
514
  return $this;
515
  }
516
 
517
  public function addUniqueArg($key, $value)
518
  {
519
  $this->smtpapi->addUniqueArg($key, $value);
520
+
521
  return $this;
522
  }
523
 
525
  public function addUniqueArgument($key, $value)
526
  {
527
  $this->smtpapi->addUniqueArg($key, $value);
528
+
529
  return $this;
530
  }
531
 
532
  public function setFilters($filter_settings)
533
  {
534
  $this->smtpapi->setFilters($filter_settings);
535
+
536
  return $this;
537
  }
538
 
540
  public function setFilterSettings($filter_settings)
541
  {
542
  $this->smtpapi->setFilters($filter_settings);
543
+
544
  return $this;
545
  }
546
 
547
  public function addFilter($filter_name, $parameter_name, $parameter_value)
548
  {
549
  $this->smtpapi->addFilter($filter_name, $parameter_name, $parameter_value);
550
+
551
  return $this;
552
  }
553
 
555
  public function addFilterSetting($filter_name, $parameter_name, $parameter_value)
556
  {
557
  $this->smtpapi->addFilter($filter_name, $parameter_name, $parameter_value);
558
+
559
  return $this;
560
  }
561
 
569
  if (count($this->getHeaders()) <= 0) {
570
  return "{}";
571
  }
572
+
573
  return json_encode($this->getHeaders(), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
574
  }
575
 
576
  public function setHeaders($key_value_pairs)
577
  {
578
  $this->headers = $key_value_pairs;
579
+
580
  return $this;
581
  }
582
 
583
  public function addHeader($key, $value)
584
  {
585
  $this->headers[$key] = $value;
586
+
587
  return $this;
588
  }
589
 
590
  public function removeHeader($key)
591
  {
592
  unset($this->headers[$key]);
593
+
594
  return $this;
595
  }
596
 
602
  public function toWebFormat()
603
  {
604
  $web = array(
605
+ 'to' => $this->to,
606
+ 'from' => $this->getFrom(),
607
+ 'x-smtpapi' => $this->smtpapi->jsonString(),
608
+ 'subject' => $this->getSubject(),
609
+ 'text' => $this->getText(),
610
+ 'html' => $this->getHtml(),
611
+ 'headers' => $this->getHeadersJson(),
612
  );
613
 
614
+ if ($this->getToNames()) {
615
+ $web['toname'] = $this->getToNames();
616
+ }
617
+ if ($this->getCcs()) {
618
+ $web['cc'] = $this->getCcs();
619
+ }
620
+ if ($this->getCcNames()) {
621
+ $web['ccname'] = $this->getCcNames();
622
+ }
623
+ if ($this->getBccs()) {
624
+ $web['bcc'] = $this->getBccs();
625
+ }
626
+ if ($this->getBccNames()) {
627
+ $web['bccname'] = $this->getBccNames();
628
+ }
629
+ if ($this->getFromName()) {
630
+ $web['fromname'] = $this->getFromName();
631
+ }
632
+ if ($this->getReplyTo()) {
633
+ $web['replyto'] = $this->getReplyTo();
634
+ }
635
+ if ($this->getDate()) {
636
+ $web['date'] = $this->getDate();
637
+ }
638
+ if ($this->smtpapi->to && (count($this->smtpapi->to) > 0)) {
639
+ $web['to'] = "";
640
+ }
641
 
642
  $web = $this->updateMissingTo($web);
643
 
644
  if ($this->getAttachments()) {
645
+ foreach ($this->getAttachments() as $f) {
646
+ $file = $f['file'];
647
+ $extension = null;
648
  if (array_key_exists('extension', $f)) {
649
+ $extension = $f['extension'];
650
  };
651
+ $filename = $f['filename'];
652
+ $full_filename = $filename;
653
 
654
  if (isset($extension)) {
655
+ $full_filename = $filename . '.' . $extension;
656
  }
657
  if (array_key_exists('custom_filename', $f)) {
658
+ $full_filename = $f['custom_filename'];
659
  }
660
 
661
  if (array_key_exists('cid', $f)) {
662
+ $web['content[' . $full_filename . ']'] = $f['cid'];
663
  }
664
 
665
+ $contents = '@' . $file;
666
 
667
  // Guzzle handles this for us.
668
  // http://guzzle3.readthedocs.org/en/latest/http-client/request.html#post-requests
670
  // $contents = new \CurlFile($file, $extension, $filename);
671
  // }
672
 
673
+ $web['files[' . $full_filename . ']'] = $contents;
674
  };
675
  }
676
 
686
  if ($this->smtpapi->to && (count($this->smtpapi->to) > 0)) {
687
  $data['to'] = $this->getFrom();
688
  }
689
+
690
  return $data;
691
  }
692
  }
vendor/sendgrid-php/lib/SendGrid/Exception.php CHANGED
@@ -7,8 +7,8 @@ namespace SendGrid;
7
  */
8
  class Exception extends \Exception
9
  {
10
- public function getErrors()
11
- {
12
- return json_decode($this->message)->errors;
13
- }
14
  }
7
  */
8
  class Exception extends \Exception
9
  {
10
+ public function getErrors()
11
+ {
12
+ return json_decode($this->message)->errors;
13
+ }
14
  }
vendor/sendgrid-php/lib/SendGrid/Response.php CHANGED
@@ -4,7 +4,6 @@ namespace SendGrid;
4
 
5
  class Response
6
  {
7
-
8
  public
9
  $code,
10
  $headers,
@@ -13,10 +12,10 @@ class Response
13
 
14
  public function __construct($code, $headers, $raw_body, $body)
15
  {
16
- $this->code = $code;
17
- $this->headers = $headers;
18
  $this->raw_body = $raw_body;
19
- $this->body = $body;
20
  }
21
 
22
  public function getCode()
4
 
5
  class Response
6
  {
 
7
  public
8
  $code,
9
  $headers,
12
 
13
  public function __construct($code, $headers, $raw_body, $body)
14
  {
15
+ $this->code = $code;
16
+ $this->headers = $headers;
17
  $this->raw_body = $raw_body;
18
+ $this->body = $body;
19
  }
20
 
21
  public function getCode()
vendor/sendgrid-php/vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
- return ComposerAutoloaderInit036e1056143d73408b319054a8c60539::getLoader();
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInit6cdb411215add3ddd507c381fb9ca2da::getLoader();
vendor/sendgrid-php/vendor/composer/autoload_namespaces.php CHANGED
@@ -6,7 +6,6 @@ $vendorDir = dirname(dirname(__FILE__));
6
  $baseDir = dirname($vendorDir);
7
 
8
  return array(
9
- 'Symfony\\Component\\EventDispatcher\\' => array($vendorDir . '/symfony/event-dispatcher'),
10
  'Smtpapi' => array($vendorDir . '/sendgrid/smtpapi/lib'),
11
  'SendGrid' => array($baseDir . '/lib'),
12
  'Guzzle\\Tests' => array($vendorDir . '/guzzle/guzzle/tests'),
6
  $baseDir = dirname($vendorDir);
7
 
8
  return array(
 
9
  'Smtpapi' => array($vendorDir . '/sendgrid/smtpapi/lib'),
10
  'SendGrid' => array($baseDir . '/lib'),
11
  'Guzzle\\Tests' => array($vendorDir . '/guzzle/guzzle/tests'),
vendor/sendgrid-php/vendor/composer/autoload_psr4.php CHANGED
@@ -6,4 +6,5 @@ $vendorDir = dirname(dirname(__FILE__));
6
  $baseDir = dirname($vendorDir);
7
 
8
  return array(
 
9
  );
6
  $baseDir = dirname($vendorDir);
7
 
8
  return array(
9
+ 'Symfony\\Component\\EventDispatcher\\' => array($vendorDir . '/symfony/event-dispatcher'),
10
  );
vendor/sendgrid-php/vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInit036e1056143d73408b319054a8c60539
6
  {
7
  private static $loader;
8
 
@@ -19,9 +19,9 @@ class ComposerAutoloaderInit036e1056143d73408b319054a8c60539
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInit036e1056143d73408b319054a8c60539', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInit036e1056143d73408b319054a8c60539', 'loadClassLoader'));
25
 
26
  $map = require __DIR__ . '/autoload_namespaces.php';
27
  foreach ($map as $namespace => $path) {
@@ -44,7 +44,7 @@ class ComposerAutoloaderInit036e1056143d73408b319054a8c60539
44
  }
45
  }
46
 
47
- function composerRequire036e1056143d73408b319054a8c60539($file)
48
  {
49
  require $file;
50
  }
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInit6cdb411215add3ddd507c381fb9ca2da
6
  {
7
  private static $loader;
8
 
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInit6cdb411215add3ddd507c381fb9ca2da', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit6cdb411215add3ddd507c381fb9ca2da', 'loadClassLoader'));
25
 
26
  $map = require __DIR__ . '/autoload_namespaces.php';
27
  foreach ($map as $namespace => $path) {
44
  }
45
  }
46
 
47
+ function composerRequire6cdb411215add3ddd507c381fb9ca2da($file)
48
  {
49
  require $file;
50
  }
vendor/sendgrid-php/vendor/composer/installed.json CHANGED
@@ -51,22 +51,21 @@
51
  },
52
  {
53
  "name": "symfony/event-dispatcher",
54
- "version": "v2.6.6",
55
- "version_normalized": "2.6.6.0",
56
- "target-dir": "Symfony/Component/EventDispatcher",
57
  "source": {
58
  "type": "git",
59
  "url": "https://github.com/symfony/EventDispatcher.git",
60
- "reference": "70f7c8478739ad21e3deef0d977b38c77f1fb284"
61
  },
62
  "dist": {
63
  "type": "zip",
64
- "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/70f7c8478739ad21e3deef0d977b38c77f1fb284",
65
- "reference": "70f7c8478739ad21e3deef0d977b38c77f1fb284",
66
  "shasum": ""
67
  },
68
  "require": {
69
- "php": ">=5.3.3"
70
  },
71
  "require-dev": {
72
  "psr/log": "~1.0",
@@ -80,16 +79,16 @@
80
  "symfony/dependency-injection": "",
81
  "symfony/http-kernel": ""
82
  },
83
- "time": "2015-03-13 17:37:22",
84
  "type": "library",
85
  "extra": {
86
  "branch-alias": {
87
- "dev-master": "2.6-dev"
88
  }
89
  },
90
  "installation-source": "source",
91
  "autoload": {
92
- "psr-0": {
93
  "Symfony\\Component\\EventDispatcher\\": ""
94
  }
95
  },
@@ -98,17 +97,17 @@
98
  "MIT"
99
  ],
100
  "authors": [
101
- {
102
- "name": "Symfony Community",
103
- "homepage": "http://symfony.com/contributors"
104
- },
105
  {
106
  "name": "Fabien Potencier",
107
  "email": "fabien@symfony.com"
 
 
 
 
108
  }
109
  ],
110
  "description": "Symfony EventDispatcher Component",
111
- "homepage": "http://symfony.com"
112
  },
113
  {
114
  "name": "guzzle/guzzle",
51
  },
52
  {
53
  "name": "symfony/event-dispatcher",
54
+ "version": "v2.7.1",
55
+ "version_normalized": "2.7.1.0",
 
56
  "source": {
57
  "type": "git",
58
  "url": "https://github.com/symfony/EventDispatcher.git",
59
+ "reference": "be3c5ff8d503c46768aeb78ce6333051aa6f26d9"
60
  },
61
  "dist": {
62
  "type": "zip",
63
+ "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/be3c5ff8d503c46768aeb78ce6333051aa6f26d9",
64
+ "reference": "be3c5ff8d503c46768aeb78ce6333051aa6f26d9",
65
  "shasum": ""
66
  },
67
  "require": {
68
+ "php": ">=5.3.9"
69
  },
70
  "require-dev": {
71
  "psr/log": "~1.0",
79
  "symfony/dependency-injection": "",
80
  "symfony/http-kernel": ""
81
  },
82
+ "time": "2015-06-08 09:37:21",
83
  "type": "library",
84
  "extra": {
85
  "branch-alias": {
86
+ "dev-master": "2.7-dev"
87
  }
88
  },
89
  "installation-source": "source",
90
  "autoload": {
91
+ "psr-4": {
92
  "Symfony\\Component\\EventDispatcher\\": ""
93
  }
94
  },
97
  "MIT"
98
  ],
99
  "authors": [
 
 
 
 
100
  {
101
  "name": "Fabien Potencier",
102
  "email": "fabien@symfony.com"
103
+ },
104
+ {
105
+ "name": "Symfony Community",
106
+ "homepage": "https://symfony.com/contributors"
107
  }
108
  ],
109
  "description": "Symfony EventDispatcher Component",
110
+ "homepage": "https://symfony.com"
111
  },
112
  {
113
  "name": "guzzle/guzzle",
vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/CHANGELOG.md → CHANGELOG.md} RENAMED
File without changes
vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php → ContainerAwareEventDispatcher.php} RENAMED
@@ -121,7 +121,7 @@ class ContainerAwareEventDispatcher extends EventDispatcher
121
  public function getListeners($eventName = null)
122
  {
123
  if (null === $eventName) {
124
- foreach (array_keys($this->listenerIds) as $serviceEventName) {
125
  $this->lazyLoad($serviceEventName);
126
  }
127
  } else {
121
  public function getListeners($eventName = null)
122
  {
123
  if (null === $eventName) {
124
+ foreach ($this->listenerIds as $serviceEventName => $args) {
125
  $this->lazyLoad($serviceEventName);
126
  }
127
  } else {
vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/Debug → Debug}/TraceableEventDispatcher.php RENAMED
@@ -31,6 +31,7 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
31
 
32
  private $called;
33
  private $dispatcher;
 
34
 
35
  /**
36
  * Constructor.
@@ -45,6 +46,7 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
45
  $this->stopwatch = $stopwatch;
46
  $this->logger = $logger;
47
  $this->called = array();
 
48
  }
49
 
50
  /**
@@ -68,6 +70,16 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
68
  */
69
  public function removeListener($eventName, $listener)
70
  {
 
 
 
 
 
 
 
 
 
 
71
  return $this->dispatcher->removeListener($eventName, $listener);
72
  }
73
 
@@ -146,7 +158,7 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
146
  $allListeners = $this->getListeners();
147
  } catch (\Exception $e) {
148
  if (null !== $this->logger) {
149
- $this->logger->info(sprintf('An exception was thrown while getting the uncalled listeners (%s)', $e->getMessage()), array('exception' => $e));
150
  }
151
 
152
  // unable to retrieve the uncalled listeners
@@ -216,12 +228,15 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
216
  $this->dispatcher->removeListener($eventName, $listener);
217
  $info = $this->getListenerInfo($listener, $eventName);
218
  $name = isset($info['class']) ? $info['class'] : $info['type'];
219
- $this->dispatcher->addListener($eventName, new WrappedListener($listener, $name, $this->stopwatch, $this));
 
 
220
  }
221
  }
222
 
223
  private function postProcess($eventName)
224
  {
 
225
  $skipped = false;
226
  foreach ($this->dispatcher->getListeners($eventName) as $listener) {
227
  if (!$listener instanceof WrappedListener) { // #12845: a new listener was added during dispatch.
@@ -259,7 +274,7 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
259
  }
260
 
261
  /**
262
- * Returns information about the listener
263
  *
264
  * @param object $listener The listener
265
  * @param string $eventName The event name
31
 
32
  private $called;
33
  private $dispatcher;
34
+ private $wrappedListeners;
35
 
36
  /**
37
  * Constructor.
46
  $this->stopwatch = $stopwatch;
47
  $this->logger = $logger;
48
  $this->called = array();
49
+ $this->wrappedListeners = array();
50
  }
51
 
52
  /**
70
  */
71
  public function removeListener($eventName, $listener)
72
  {
73
+ if (isset($this->wrappedListeners[$eventName])) {
74
+ foreach ($this->wrappedListeners[$eventName] as $index => $wrappedListener) {
75
+ if ($wrappedListener->getWrappedListener() === $listener) {
76
+ $listener = $wrappedListener;
77
+ unset($this->wrappedListeners[$eventName][$index]);
78
+ break;
79
+ }
80
+ }
81
+ }
82
+
83
  return $this->dispatcher->removeListener($eventName, $listener);
84
  }
85
 
158
  $allListeners = $this->getListeners();
159
  } catch (\Exception $e) {
160
  if (null !== $this->logger) {
161
+ $this->logger->info('An exception was thrown while getting the uncalled listeners.', array('exception' => $e));
162
  }
163
 
164
  // unable to retrieve the uncalled listeners
228
  $this->dispatcher->removeListener($eventName, $listener);
229
  $info = $this->getListenerInfo($listener, $eventName);
230
  $name = isset($info['class']) ? $info['class'] : $info['type'];
231
+ $wrappedListener = new WrappedListener($listener, $name, $this->stopwatch, $this);
232
+ $this->wrappedListeners[$eventName][] = $wrappedListener;
233
+ $this->dispatcher->addListener($eventName, $wrappedListener);
234
  }
235
  }
236
 
237
  private function postProcess($eventName)
238
  {
239
+ unset($this->wrappedListeners[$eventName]);
240
  $skipped = false;
241
  foreach ($this->dispatcher->getListeners($eventName) as $listener) {
242
  if (!$listener instanceof WrappedListener) { // #12845: a new listener was added during dispatch.
274
  }
275
 
276
  /**
277
+ * Returns information about the listener.
278
  *
279
  * @param object $listener The listener
280
  * @param string $eventName The event name
vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/Debug → Debug}/TraceableEventDispatcherInterface.php RENAMED
File without changes
vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/Debug → Debug}/WrappedListener.php RENAMED
File without changes
vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/DependencyInjection → DependencyInjection}/RegisterListenersPass.php RENAMED
File without changes
vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/Event.php → Event.php} RENAMED
@@ -77,7 +77,7 @@ class Event
77
  *
78
  * @param EventDispatcherInterface $dispatcher
79
  *
80
- * @deprecated Deprecated in 2.4, to be removed in 3.0. The event dispatcher is passed to the listener call.
81
  *
82
  * @api
83
  */
@@ -91,12 +91,14 @@ class Event
91
  *
92
  * @return EventDispatcherInterface
93
  *
94
- * @deprecated Deprecated in 2.4, to be removed in 3.0. The event dispatcher is passed to the listener call.
95
  *
96
  * @api
97
  */
98
  public function getDispatcher()
99
  {
 
 
100
  return $this->dispatcher;
101
  }
102
 
@@ -105,12 +107,14 @@ class Event
105
  *
106
  * @return string
107
  *
108
- * @deprecated Deprecated in 2.4, to be removed in 3.0. The event name is passed to the listener call.
109
  *
110
  * @api
111
  */
112
  public function getName()
113
  {
 
 
114
  return $this->name;
115
  }
116
 
@@ -119,7 +123,7 @@ class Event
119
  *
120
  * @param string $name The event name.
121
  *
122
- * @deprecated Deprecated in 2.4, to be removed in 3.0. The event name is passed to the listener call.
123
  *
124
  * @api
125
  */
77
  *
78
  * @param EventDispatcherInterface $dispatcher
79
  *
80
+ * @deprecated since version 2.4, to be removed in 3.0. The event dispatcher is passed to the listener call.
81
  *
82
  * @api
83
  */
91
  *
92
  * @return EventDispatcherInterface
93
  *
94
+ * @deprecated since version 2.4, to be removed in 3.0. The event dispatcher is passed to the listener call.
95
  *
96
  * @api
97
  */
98
  public function getDispatcher()
99
  {
100
+ @trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in 3.0. The event dispatcher instance can be received in the listener call instead.', E_USER_DEPRECATED);
101
+
102
  return $this->dispatcher;
103
  }
104
 
107
  *
108
  * @return string
109
  *
110
+ * @deprecated since version 2.4, to be removed in 3.0. The event name is passed to the listener call.
111
  *
112
  * @api
113
  */
114
  public function getName()
115
  {
116
+ @trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in 3.0. The event name can be received in the listener call instead.', E_USER_DEPRECATED);
117
+
118
  return $this->name;
119
  }
120
 
123
  *
124
  * @param string $name The event name.
125
  *
126
+ * @deprecated since version 2.4, to be removed in 3.0. The event name is passed to the listener call.
127
  *
128
  * @api
129
  */
vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/EventDispatcher.php → EventDispatcher.php} RENAMED
@@ -68,7 +68,7 @@ class EventDispatcher implements EventDispatcherInterface
68
  return $this->sorted[$eventName];
69
  }
70
 
71
- foreach (array_keys($this->listeners) as $eventName) {
72
  if (!isset($this->sorted[$eventName])) {
73
  $this->sortListeners($eventName);
74
  }
68
  return $this->sorted[$eventName];
69
  }
70
 
71
+ foreach ($this->listeners as $eventName => $eventListeners) {
72
  if (!isset($this->sorted[$eventName])) {
73
  $this->sortListeners($eventName);
74
  }
vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/EventDispatcherInterface.php → EventDispatcherInterface.php} RENAMED
@@ -77,7 +77,7 @@ interface EventDispatcherInterface
77
  public function removeSubscriber(EventSubscriberInterface $subscriber);
78
 
79
  /**
80
- * Gets the listeners of a specific event or all listeners.
81
  *
82
  * @param string $eventName The name of the event
83
  *
77
  public function removeSubscriber(EventSubscriberInterface $subscriber);
78
 
79
  /**
80
+ * Gets the listeners of a specific event or all listeners sorted by descending priority.
81
  *
82
  * @param string $eventName The name of the event
83
  *
vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/EventSubscriberInterface.php → EventSubscriberInterface.php} RENAMED
File without changes
vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/GenericEvent.php → GenericEvent.php} RENAMED
@@ -71,7 +71,7 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
71
  return $this->arguments[$key];
72
  }
73
 
74
- throw new \InvalidArgumentException(sprintf('%s not found in %s', $key, $this->getName()));
75
  }
76
 
77
  /**
71
  return $this->arguments[$key];
72
  }
73
 
74
+ throw new \InvalidArgumentException(sprintf('Argument "%s" not found.', $key));
75
  }
76
 
77
  /**
vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php → ImmutableEventDispatcher.php} RENAMED
File without changes
vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/LICENSE → LICENSE} RENAMED
File without changes
vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/README.md → README.md} RENAMED
File without changes
vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/Tests → Tests}/AbstractEventDispatcherTest.php RENAMED
@@ -118,10 +118,21 @@ abstract class AbstractEventDispatcherTest extends \PHPUnit_Framework_TestCase
118
  $this->assertInstanceOf('Symfony\Component\EventDispatcher\Event', $this->dispatcher->dispatch(self::preFoo));
119
  $event = new Event();
120
  $return = $this->dispatcher->dispatch(self::preFoo, $event);
121
- $this->assertEquals('pre.foo', $event->getName());
122
  $this->assertSame($event, $return);
123
  }
124
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  public function testDispatchForClosure()
126
  {
127
  $invoked = 0;
@@ -239,8 +250,13 @@ abstract class AbstractEventDispatcherTest extends \PHPUnit_Framework_TestCase
239
  $this->assertFalse($this->dispatcher->hasListeners(self::preFoo));
240
  }
241
 
242
- public function testEventReceivesTheDispatcherInstance()
 
 
 
243
  {
 
 
244
  $dispatcher = null;
245
  $this->dispatcher->addListener('test', function ($event) use (&$dispatcher) {
246
  $dispatcher = $event->getDispatcher();
118
  $this->assertInstanceOf('Symfony\Component\EventDispatcher\Event', $this->dispatcher->dispatch(self::preFoo));
119
  $event = new Event();
120
  $return = $this->dispatcher->dispatch(self::preFoo, $event);
 
121
  $this->assertSame($event, $return);
122
  }
123
 
124
+ /**
125
+ * @group legacy
126
+ */
127
+ public function testLegacyDispatch()
128
+ {
129
+ $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
130
+
131
+ $event = new Event();
132
+ $return = $this->dispatcher->dispatch(self::preFoo, $event);
133
+ $this->assertEquals('pre.foo', $event->getName());
134
+ }
135
+
136
  public function testDispatchForClosure()
137
  {
138
  $invoked = 0;
250
  $this->assertFalse($this->dispatcher->hasListeners(self::preFoo));
251
  }
252
 
253
+ /**
254
+ * @group legacy
255
+ */
256
+ public function testLegacyEventReceivesTheDispatcherInstance()
257
  {
258
+ $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
259
+
260
  $dispatcher = null;
261
  $this->dispatcher->addListener('test', function ($event) use (&$dispatcher) {
262
  $dispatcher = $event->getDispatcher();
vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/Tests → Tests}/ContainerAwareEventDispatcherTest.php RENAMED
File without changes
vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/Tests → Tests}/Debug/TraceableEventDispatcherTest.php RENAMED
@@ -12,6 +12,7 @@
12
  namespace Symfony\Component\EventDispatcher\Tests\Debug;
13
 
14
  use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher;
 
15
  use Symfony\Component\EventDispatcher\EventSubscriberInterface;
16
  use Symfony\Component\EventDispatcher\EventDispatcher;
17
  use Symfony\Component\EventDispatcher\Event;
@@ -174,6 +175,19 @@ class TraceableEventDispatcherTest extends \PHPUnit_Framework_TestCase
174
  $dispatcher->dispatch('foo');
175
  $this->assertTrue($nestedCall);
176
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
177
  }
178
 
179
  class EventSubscriber implements EventSubscriberInterface
12
  namespace Symfony\Component\EventDispatcher\Tests\Debug;
13
 
14
  use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher;
15
+ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
16
  use Symfony\Component\EventDispatcher\EventSubscriberInterface;
17
  use Symfony\Component\EventDispatcher\EventDispatcher;
18
  use Symfony\Component\EventDispatcher\Event;
175
  $dispatcher->dispatch('foo');
176
  $this->assertTrue($nestedCall);
177
  }
178
+
179
+ public function testListenerCanRemoveItselfWhenExecuted()
180
+ {
181
+ $eventDispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch());
182
+ $listener1 = function ($event, $eventName, EventDispatcherInterface $dispatcher) use (&$listener1) {
183
+ $dispatcher->removeListener('foo', $listener1);
184
+ };
185
+ $eventDispatcher->addListener('foo', $listener1);
186
+ $eventDispatcher->addListener('foo', function () {});
187
+ $eventDispatcher->dispatch('foo');
188
+
189
+ $this->assertCount(1, $eventDispatcher->getListeners('foo'), 'expected listener1 to be removed');
190
+ }
191
  }
192
 
193
  class EventSubscriber implements EventSubscriberInterface
vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/Tests → Tests}/DependencyInjection/RegisterListenersPassTest.php RENAMED
File without changes
vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/Tests → Tests}/EventDispatcherTest.php RENAMED
File without changes
vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/Tests → Tests}/EventTest.php RENAMED
File without changes
vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/Tests → Tests}/GenericEventTest.php RENAMED
File without changes
vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/Tests → Tests}/ImmutableEventDispatcherTest.php RENAMED
File without changes
vendor/sendgrid-php/vendor/symfony/event-dispatcher/{Symfony/Component/EventDispatcher/phpunit.xml.dist → phpunit.xml.dist} RENAMED
@@ -9,6 +9,7 @@
9
  <php>
10
  <ini name="error_reporting" value="-1" />
11
  </php>
 
12
  <testsuites>
13
  <testsuite name="Symfony EventDispatcher Component Test Suite">
14
  <directory>./Tests/</directory>
9
  <php>
10
  <ini name="error_reporting" value="-1" />
11
  </php>
12
+
13
  <testsuites>
14
  <testsuite name="Symfony EventDispatcher Component Test Suite">
15
  <directory>./Tests/</directory>
view/css/sendgrid.css CHANGED
@@ -374,4 +374,8 @@
374
  margin-left: 2.3%;
375
  width: 95.4%;
376
  }
 
 
 
 
377
  }
374
  margin-left: 2.3%;
375
  width: 95.4%;
376
  }
377
+ }
378
+
379
+ .creds {
380
+ display: none;
381
  }
view/js/sendgrid.settings.js ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function($) {
2
+
3
+ if ( $('#auth_method').find("option:selected").val() == 'apikey' ) {
4
+ $(".apikey").show();
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
+ });
view/js/sendgrid.stats.js CHANGED
@@ -114,6 +114,7 @@ jQuery(document).ready(function($) {
114
  }
115
  jQuery.each(response, function(key, value) {
116
  var dateString = _splitDate(value.date);
 
117
  var date = Date.UTC(dateString[0], _convertMonthToUTC(dateString[1]), dateString[2]);
118
  var requestsThisDay = value.requests ? value.requests : 0;
119
  var opensThisDay = value.opens ? value.opens : 0;
114
  }
115
  jQuery.each(response, function(key, value) {
116
  var dateString = _splitDate(value.date);
117
+ value = value.stats[0].metrics;
118
  var date = Date.UTC(dateString[0], _convertMonthToUTC(dateString[1]), dateString[2]);
119
  var requestsThisDay = value.requests ? value.requests : 0;
120
  var opensThisDay = value.opens ? value.opens : 0;
view/sendgrid_settings.php CHANGED
@@ -14,23 +14,41 @@
14
  <form class="form-table" name="sendgrid_form" method="POST" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI'] ); ?>">
15
  <table class="form-table">
16
  <tbody>
17
- <tr valign="top">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  <th scope="row"><?php _e("Username: "); ?></th>
19
  <td>
20
- <input type="text" required="true" name="sendgrid_user" value="<?php echo $user; ?>" size="20" class="regular-text" <?php disabled( $are_global_credentials ); ?>>
21
  </td>
22
  </tr>
23
- <tr valign="top">
24
  <th scope="row"><?php _e("Password: "); ?></th>
25
  <td>
26
- <input type="password" required="true" name="sendgrid_pwd" value="<?php echo ( $are_global_credentials ? "******" : $password ); ?>" size="20" class="regular-text" <?php disabled( $are_global_credentials ); ?>>
27
  </td>
28
  </tr>
29
- <?php if ( $are_global_credentials ): ?>
30
  <tr valign="top">
31
  <td colspan="2">
32
  <p>
33
- <?php _e('Your credentials are already configured in the config file. You can not, also, specify them in the interface.'); ?>
 
 
 
34
  </p>
35
  </td>
36
  </tr>
@@ -38,7 +56,7 @@
38
  <tr valign="top">
39
  <th scope="row"><?php _e("Send Mail with: "); ?></th>
40
  <td>
41
- <select name="sendgrid_api" <?php disabled( defined('SENDGRID_SEND_METHOD') ); ?>>
42
  <option value="api" id="api" <?php echo ( 'api' == $method ) ? 'selected' : '' ?>><?php _e('API') ?></option>
43
  <option value="smtp" id="smtp" <?php echo ( 'smtp' == $method ) ? 'selected' : '' ?>><?php _e('SMTP') ?></option>
44
  </select>
@@ -61,7 +79,7 @@
61
  <th scope="row"><?php _e("Sending Address: "); ?></th>
62
  <td>
63
  <input type="email" name="sendgrid_email" value="<?php echo $email; ?>" size="20" class="regular-text" <?php disabled( defined('SENDGRID_FROM_EMAIL') ); ?>>
64
- <p class="description"><?php _e('Email address from which the message will be sent,') ?></p>
65
  </td>
66
  </tr>
67
  <tr valign="top">
14
  <form class="form-table" name="sendgrid_form" method="POST" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI'] ); ?>">
15
  <table class="form-table">
16
  <tbody>
17
+ <tr valign="top">
18
+ <th scope="row"><?php _e("Authentication method: "); ?></th>
19
+ <td>
20
+ <select name="auth_method" id="auth_method" <?php disabled( defined('SENDGRID_AUTH_METHOD') or ( $is_global_api_key or $are_global_credentials ) ); ?>>
21
+ <option value="apikey" id="apikey" <?php echo ( 'apikey' == $auth_method ) ? 'selected' : '' ?>><?php _e('Api Key') ?></option>
22
+ <option value="username" id="username" <?php echo ( 'username' == $auth_method ) ? 'selected' : '' ?>><?php _e('Username&Password') ?></option>
23
+ </select>
24
+ </td>
25
+ </tr>
26
+ <tr valign="top" class="apikey">
27
+ <th scope="row"><?php _e("API key: "); ?></th>
28
+ <td>
29
+ <input type="password" name="sendgrid_api_key" value="<?php echo ( $is_global_api_key ? "************" : $api_key ); ?>" size="50" <?php disabled( $is_global_api_key ); ?>>
30
+ </td>
31
+ </tr>
32
+ <tr valign="top" class="creds">
33
  <th scope="row"><?php _e("Username: "); ?></th>
34
  <td>
35
+ <input type="text" name="sendgrid_user" value="<?php echo $user; ?>" size="20" class="regular-text" <?php disabled( $are_global_credentials ); ?>>
36
  </td>
37
  </tr>
38
+ <tr valign="top" class="creds">
39
  <th scope="row"><?php _e("Password: "); ?></th>
40
  <td>
41
+ <input type="password" name="sendgrid_pwd" value="<?php echo ( $are_global_credentials ? "******" : $password ); ?>" size="20" class="regular-text" <?php disabled( $are_global_credentials ); ?>>
42
  </td>
43
  </tr>
44
+ <?php if ( $are_global_credentials or $is_global_api_key): ?>
45
  <tr valign="top">
46
  <td colspan="2">
47
  <p>
48
+ <?php _e('Your credentials are already configured in the config file. If you want to manage them from the interface, remove them from config.'); ?>
49
+ </p>
50
+ <p>
51
+ <?php _e('If you have both credential types set, by default the Api Key credential is used.'); ?>
52
  </p>
53
  </td>
54
  </tr>
56
  <tr valign="top">
57
  <th scope="row"><?php _e("Send Mail with: "); ?></th>
58
  <td>
59
+ <select name="sendgrid_api" id="sendgrid_api" <?php disabled( defined('SENDGRID_SEND_METHOD') ); ?>>
60
  <option value="api" id="api" <?php echo ( 'api' == $method ) ? 'selected' : '' ?>><?php _e('API') ?></option>
61
  <option value="smtp" id="smtp" <?php echo ( 'smtp' == $method ) ? 'selected' : '' ?>><?php _e('SMTP') ?></option>
62
  </select>
79
  <th scope="row"><?php _e("Sending Address: "); ?></th>
80
  <td>
81
  <input type="email" name="sendgrid_email" value="<?php echo $email; ?>" size="20" class="regular-text" <?php disabled( defined('SENDGRID_FROM_EMAIL') ); ?>>
82
+ <p class="description"><?php _e('Email address from which the message will be sent.') ?></p>
83
  </td>
84
  </tr>
85
  <tr valign="top">
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.1
7
  Author: SendGrid
8
  Author URI: http://sendgrid.com
9
  License: GPLv2
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.2
7
  Author: SendGrid
8
  Author URI: http://sendgrid.com
9
  License: GPLv2