wpMandrill - Version 1.21

Version Description

  • FIXED: Logging wrong error messages when sending emails with no attachments
  • FIXED: Attachments that Mandrill doesn't support were discarded instead of sending the email (with attachment) through the native wp_mail function.
  • ADDED: Added support Audio and Video file attachments.
  • FIXED: Valid Domains matching is NOT case-sensitive now.
  • FIXED: Better error reporting on Dashboard widgets.
  • FIXED: Validating FROM: email address after mandrill_payload has been processed.
Download this release

Release Info

Developer MC_Will
Plugin Icon wp plugin wpMandrill
Version 1.21
Comparing to
See all releases

Code changes from version 1.20 to 1.21

Files changed (3) hide show
  1. lib/mandrill.class.php +4 -7
  2. readme.txt +10 -1
  3. wpmandrill.php +46 -35
lib/mandrill.class.php CHANGED
@@ -94,14 +94,9 @@ class Mandrill {
94
  }
95
 
96
  if( 200 == $response_code ) {
97
-
98
  return $body;
99
- }
100
- else {
101
-
102
- $message = isset( $body['message'] ) ? $body['message'] : '' ;
103
-
104
- throw new Mandrill_Exception($message . ' - ' . $body, $response_code);
105
  }
106
  }
107
 
@@ -580,6 +575,8 @@ class Mandrill {
580
  'image/',
581
  'text/',
582
  'application/pdf',
 
 
583
  );
584
  }
585
  }
94
  }
95
 
96
  if( 200 == $response_code ) {
 
97
  return $body;
98
+ } else {
99
+ throw new Mandrill_Exception( "HTTP Code $response_code: $url", $response_code);
 
 
 
 
100
  }
101
  }
102
 
575
  'image/',
576
  'text/',
577
  'application/pdf',
578
+ 'audio/',
579
+ 'video/'
580
  );
581
  }
582
  }
readme.txt CHANGED
@@ -2,8 +2,9 @@
2
  Contributors: MC_Will
3
  Tags: mandrill, mailchimp, transactional email, email, email reliability, smtp, wp_mail, email templates
4
  Requires at least: 3.0
5
- Tested up to: 3.3.2
6
  Stable tag: trunk
 
7
 
8
  The wpMandrill plugin sends emails that are generated by WordPress through Mandrill, a transactional email service powered by MailChimp.
9
 
@@ -83,6 +84,14 @@ If your account has more than 20 senders registered or more than 40 tags used, t
83
 
84
  == Changelog ==
85
 
 
 
 
 
 
 
 
 
86
  = 1.20 =
87
  * ADDED: Mandrill's Privacy Policy and Terms of Use
88
  * FIXED: Sending more than one attachment was failing
2
  Contributors: MC_Will
3
  Tags: mandrill, mailchimp, transactional email, email, email reliability, smtp, wp_mail, email templates
4
  Requires at least: 3.0
5
+ Tested up to: 3.4.1
6
  Stable tag: trunk
7
+ License: GPLv2
8
 
9
  The wpMandrill plugin sends emails that are generated by WordPress through Mandrill, a transactional email service powered by MailChimp.
10
 
84
 
85
  == Changelog ==
86
 
87
+ = 1.21 =
88
+ * FIXED: Logging wrong error messages when sending emails with no attachments
89
+ * FIXED: Attachments that Mandrill doesn't support were discarded instead of sending the email (with attachment) through the native wp_mail function.
90
+ * ADDED: Added support Audio and Video file attachments.
91
+ * FIXED: Valid Domains matching is NOT case-sensitive now.
92
+ * FIXED: Better error reporting on Dashboard widgets.
93
+ * FIXED: Validating FROM: email address after mandrill_payload has been processed.
94
+
95
  = 1.20 =
96
  * ADDED: Mandrill's Privacy Policy and Terms of Use
97
  * FIXED: Sending more than one attachment was failing
wpmandrill.php CHANGED
@@ -5,7 +5,7 @@ Description: wpMandrill sends emails, generated by WordPress using Mandrill.
5
  Author: Mandrill
6
  Author URI: http://mandrillapp.com/
7
  Plugin URI: http://connect.mailchimp.com/integrations/wpmandrill
8
- Version: 1.20
9
  Text Domain: wpmandrill
10
  */
11
  /* Copyright 2012 MailChimp (email : will@mailchimp.com )
@@ -68,7 +68,7 @@ class wpMandrill {
68
 
69
  if ( is_wp_error($sent)
70
  || !isset($sent[0]['status'])
71
- || ( isset($sent[0]['status']) && 'sent' != $sent[0]['status'] ) ) {
72
 
73
  return wpMandrill::wp_mail_native( $to, $subject, $message, $headers, $attachments );
74
  }
@@ -616,7 +616,7 @@ jQuery(document).bind( 'ready', function() {
616
 
617
  $domains = self::ListVerifiedDomains();
618
  foreach ( $domains as $curdomain ) {
619
- if ( $curdomain['domain'] == $domain ) {
620
  return true;
621
  }
622
  }
@@ -1074,32 +1074,38 @@ jQuery(document).bind( 'ready', function() {
1074
  $display = $widget_options[$widget_id]['display'];
1075
  }
1076
 
1077
- $stats = array();
1078
- if ( $filter == 'none' ) {
1079
- $filter_type = 'account';
1080
- $filter_used = '';
1081
-
1082
- $data = self::$mandrill->users_info();
1083
- $stats['stats']['periods']['account']['today'] = $data['stats']['today'];
1084
- $stats['stats']['periods']['account']['last_7_days'] = $data['stats']['last_7_days'];
1085
-
1086
- } elseif ( substr($filter,0,2) == 's:' ) {
1087
- $filter_type = 'senders';
1088
- $filter = substr($filter,2);
1089
- $filter_used = 'Filtering by sender: '.$filter;
1090
-
1091
- $data = self::$mandrill->senders_info($filter);
1092
- $stats['stats']['periods']['senders']['today'][$filter] = $data['stats']['today'];
1093
- $stats['stats']['periods']['senders']['last_7_days'][$filter] = $data['stats']['last_7_days'];
1094
- } else {
1095
- $filter_type = 'tags';
1096
- $filter_used = 'Filtering by tag: '.$filter;
1097
-
1098
- $data = self::$mandrill->tags_info($filter);
1099
- $stats['stats']['periods']['tags']['today'][$filter] = $data['stats']['today'];
1100
- $stats['stats']['periods']['tags']['last_7_days'][$filter] = $data['stats']['last_7_days'];
 
 
 
 
 
 
 
1101
  }
1102
-
1103
  $data = array();
1104
  foreach ( array('today', 'last_7_days') as $period ) {
1105
  if ( $filter_type == 'account' ) {
@@ -1789,7 +1795,7 @@ JS;
1789
  }
1790
  }
1791
 
1792
- // Adding a Reply-To header is needed.
1793
  $reply_to = self::getReplyTo();
1794
  if ( !empty($reply_to) && !in_array( 'reply_to', array_map( 'strtolower', array_keys($message['headers']) ) ) ) {
1795
  $message['headers']['Reply-To'] = trim(self::getReplyTo());
@@ -1807,17 +1813,17 @@ JS;
1807
  // Checking the From: field
1808
  if ( empty($message['from_email']) ) $message['from_email'] = self::getFromEmail();
1809
  if ( empty($message['from_name'] ) ) $message['from_name'] = self::getFromName();
1810
-
1811
- list($dummy,$domain) = explode('@', $message['from_email']);
1812
- if ( !self::isDomainEnabled( $domain ) )
1813
- throw new Exception('The domain of the email you provided has not been verified by Mandrill.');
1814
 
1815
  // Checking the tags.
1816
  $message['tags'] = self::findTags($tags);
1817
 
1818
  // Checking the attachments
1819
- $message['attachments'] = self::processAttachments($message['attachments']);
1820
-
 
 
 
 
1821
  // Default values for other parameters
1822
  $message['auto_text'] = true;
1823
  $message['track_opens'] = $track_opens;
@@ -1853,6 +1859,11 @@ JS;
1853
  error_log( "\nwpMandrill::sendEmail: After mandrill_payload ".print_r($message,true)."\n" );
1854
  }
1855
 
 
 
 
 
 
1856
  // Setting the tags property correctly to be received by the Mandrill's API
1857
  if ( !is_array($message['tags']['user']) ) $message['tags']['user'] = array();
1858
  if ( !is_array($message['tags']['general']) ) $message['tags']['general'] = array();
5
  Author: Mandrill
6
  Author URI: http://mandrillapp.com/
7
  Plugin URI: http://connect.mailchimp.com/integrations/wpmandrill
8
+ Version: 1.21
9
  Text Domain: wpmandrill
10
  */
11
  /* Copyright 2012 MailChimp (email : will@mailchimp.com )
68
 
69
  if ( is_wp_error($sent)
70
  || !isset($sent[0]['status'])
71
+ || $sent[0]['status'] != 'sent' ) {
72
 
73
  return wpMandrill::wp_mail_native( $to, $subject, $message, $headers, $attachments );
74
  }
616
 
617
  $domains = self::ListVerifiedDomains();
618
  foreach ( $domains as $curdomain ) {
619
+ if ( strtolower($curdomain['domain']) == strtolower($domain) ) {
620
  return true;
621
  }
622
  }
1074
  $display = $widget_options[$widget_id]['display'];
1075
  }
1076
 
1077
+ try {
1078
+ $stats = array();
1079
+ if ( $filter == 'none' ) {
1080
+ $filter_type = 'account';
1081
+ $filter_used = '';
1082
+
1083
+ $data = self::$mandrill->users_info();
1084
+ $stats['stats']['periods']['account']['today'] = $data['stats']['today'];
1085
+ $stats['stats']['periods']['account']['last_7_days'] = $data['stats']['last_7_days'];
1086
+
1087
+ } elseif ( substr($filter,0,2) == 's:' ) {
1088
+ $filter_type = 'senders';
1089
+ $filter = substr($filter,2);
1090
+ $filter_used = 'Filtering by sender: '.$filter;
1091
+
1092
+ $data = self::$mandrill->senders_info($filter);
1093
+ $stats['stats']['periods']['senders']['today'][$filter] = $data['stats']['today'];
1094
+ $stats['stats']['periods']['senders']['last_7_days'][$filter] = $data['stats']['last_7_days'];
1095
+ } else {
1096
+ $filter_type = 'tags';
1097
+ $filter_used = 'Filtering by tag: '.$filter;
1098
+
1099
+ $data = self::$mandrill->tags_info($filter);
1100
+ $stats['stats']['periods']['tags']['today'][$filter] = $data['stats']['today'];
1101
+ $stats['stats']['periods']['tags']['last_7_days'][$filter] = $data['stats']['last_7_days'];
1102
+ }
1103
+ } catch ( Exception $e ) {
1104
+ if ( $isAjaxCall ) exit();
1105
+
1106
+ echo '<div style="height:400px;"><div id="filtered_recent">Error trying to read data from Mandrill: '.$e->getMessage().'</div></div>';
1107
+ return;
1108
  }
 
1109
  $data = array();
1110
  foreach ( array('today', 'last_7_days') as $period ) {
1111
  if ( $filter_type == 'account' ) {
1795
  }
1796
  }
1797
 
1798
+ // Adding a Reply-To header if needed.
1799
  $reply_to = self::getReplyTo();
1800
  if ( !empty($reply_to) && !in_array( 'reply_to', array_map( 'strtolower', array_keys($message['headers']) ) ) ) {
1801
  $message['headers']['Reply-To'] = trim(self::getReplyTo());
1813
  // Checking the From: field
1814
  if ( empty($message['from_email']) ) $message['from_email'] = self::getFromEmail();
1815
  if ( empty($message['from_name'] ) ) $message['from_name'] = self::getFromName();
 
 
 
 
1816
 
1817
  // Checking the tags.
1818
  $message['tags'] = self::findTags($tags);
1819
 
1820
  // Checking the attachments
1821
+ if ( !empty($message['attachments']) ) {
1822
+ $message['attachments'] = self::processAttachments($message['attachments']);
1823
+ if ( is_wp_error($message['attachments']) ) {
1824
+ throw new Exception('Invalid attachment (check http://eepurl.com/nXMa1 for supported file types).');
1825
+ }
1826
+ }
1827
  // Default values for other parameters
1828
  $message['auto_text'] = true;
1829
  $message['track_opens'] = $track_opens;
1859
  error_log( "\nwpMandrill::sendEmail: After mandrill_payload ".print_r($message,true)."\n" );
1860
  }
1861
 
1862
+ // Checking that the final From: email address is valid
1863
+ list($dummy,$domain) = explode('@', $message['from_email']);
1864
+ if ( !self::isDomainEnabled( $domain ) )
1865
+ throw new Exception('The domain of the email you provided ('.$domain.') has not been added to Mandrill yet.');
1866
+
1867
  // Setting the tags property correctly to be received by the Mandrill's API
1868
  if ( !is_array($message['tags']['user']) ) $message['tags']['user'] = array();
1869
  if ( !is_array($message['tags']['general']) ) $message['tags']['general'] = array();