wpMandrill - Version 1.28

Version Description

  • ADDED: If you want to fall back some of your emails to the native wp_mail function, now you can do it by using the mandrill_payload filter and setting a parameter called 'force_native' to true.
  • REMOVED: Mime type checking on attachments.
  • ADDED: Sending MIME TYPE of attachments to Mandrill only when wpMandrill is able to find it.
Download this release

Release Info

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

Code changes from version 1.27 to 1.28

Files changed (3) hide show
  1. lib/mandrill.class.php +6 -7
  2. readme.txt +16 -4
  3. wpmandrill.php +3 -1
lib/mandrill.class.php CHANGED
@@ -96,7 +96,8 @@ class Mandrill {
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
 
@@ -538,17 +539,15 @@ class Mandrill {
538
 
539
  if (strnatcmp(phpversion(),'6') >= 0) set_magic_quotes_runtime($magic_quotes);
540
 
541
- if (strnatcmp(phpversion(),'5.3') >= 0) {
 
542
  $finfo = finfo_open(FILEINFO_MIME_TYPE);
543
  $mime_type = finfo_file($finfo, $path);
544
- } else {
545
  $mime_type = mime_content_type($path);
546
  }
547
-
548
- if ( !Mandrill::isValidContentType($mime_type) )
549
- throw new Exception($mime_type.' is not a valid content type (it should be '.implode('*,', self::getValidContentTypes() ).').');
550
 
551
- $struct['type'] = $mime_type;
552
  $struct['name'] = $filename;
553
  $struct['content'] = $file_buffer;
554
 
96
  if( 200 == $response_code ) {
97
  return $body;
98
  } else {
99
+ error_log("wpMandrill Error: Error {$body['code']}: {$body['message']}");
100
+ throw new Mandrill_Exception( "wpMandrill Error: {$body['code']}: {$body['message']}", $response_code);
101
  }
102
  }
103
 
539
 
540
  if (strnatcmp(phpversion(),'6') >= 0) set_magic_quotes_runtime($magic_quotes);
541
 
542
+ $mime_type = '';
543
+ if (strnatcmp(phpversion(),'5.3') >= 0) {
544
  $finfo = finfo_open(FILEINFO_MIME_TYPE);
545
  $mime_type = finfo_file($finfo, $path);
546
+ } elseif ( function_exists('mime_content_type') ) {
547
  $mime_type = mime_content_type($path);
548
  }
 
 
 
549
 
550
+ if ( !empty($mime_type) ) $struct['type'] = $mime_type;
551
  $struct['name'] = $filename;
552
  $struct['content'] = $file_buffer;
553
 
readme.txt CHANGED
@@ -43,21 +43,29 @@ In order to use this plugin, you have to provide one of your Mandrill API keys.
43
 
44
  = Do I need a MailChimp account? =
45
 
46
- Not anymore!
47
 
48
- = Is all email routed through Mandrill? =
49
 
50
  Yes. We try to send every single email sent through your WordPress installation. We also try to process your headers and attachments.
51
 
52
  If the sending fails for any reason, the plugin will try to send it again using the WordPress wp_mail function.
53
 
 
 
 
 
 
 
54
  = My emails are broken and show weird CSS code =
55
 
56
  In version 1.09, we added a setting that allows you to tell the plugin if you want to replace your line feeds by <br/>. Try playing with that switch. If it works for certain emails doesn't for others, then you should customize the payload sent to Mandrill using the **mandrill_payload** plugin.
57
 
58
  = Is there any way to check what's going on? =
59
 
60
- If you set the WP_DEBUG constant (defined in your wp-config.php file) to true, you'll see some messages added by the plugin in key parts of the process.
 
 
61
 
62
  = I am getting an Invalid API Key message and I'm sure my API is valid!
63
 
@@ -91,7 +99,11 @@ If your account has more than 20 senders registered or more than 40 tags used, t
91
  4. Dashboard widget Settings
92
 
93
  == Changelog ==
94
-
 
 
 
 
95
  = 1.27 =
96
  * FIXED: Removing php short tags. ** Thanks Kailey Lampert! **
97
 
43
 
44
  = Do I need a MailChimp account? =
45
 
46
+ Nop.
47
 
48
+ = Are all emails routed through Mandrill? =
49
 
50
  Yes. We try to send every single email sent through your WordPress installation. We also try to process your headers and attachments.
51
 
52
  If the sending fails for any reason, the plugin will try to send it again using the WordPress wp_mail function.
53
 
54
+ = What if I need to send some of my emails using the native wp_mail() function?
55
+
56
+ Use the mandrill_payload filter and add a new parameter called 'force_native' to the $message variable, and set it to true:
57
+
58
+ $message['force_native'] = true;
59
+
60
  = My emails are broken and show weird CSS code =
61
 
62
  In version 1.09, we added a setting that allows you to tell the plugin if you want to replace your line feeds by <br/>. Try playing with that switch. If it works for certain emails doesn't for others, then you should customize the payload sent to Mandrill using the **mandrill_payload** plugin.
63
 
64
  = Is there any way to check what's going on? =
65
 
66
+ If we couldn't send your email through Mandrill, we'll try to leave the Mandrill response in your server's log so that's your first stop.
67
+
68
+ Additionaly, if you set the WP_DEBUG constant (defined in your wp-config.php file) to true, you'll see some messages added by the plugin in key parts of the process.
69
 
70
  = I am getting an Invalid API Key message and I'm sure my API is valid!
71
 
99
  4. Dashboard widget Settings
100
 
101
  == Changelog ==
102
+ = 1.28 =
103
+ * ADDED: If you want to fall back some of your emails to the native wp_mail function, now you can do it by using the mandrill_payload filter and setting a parameter called 'force_native' to true.
104
+ * REMOVED: Mime type checking on attachments.
105
+ * ADDED: Sending MIME TYPE of attachments to Mandrill only when wpMandrill is able to find it.
106
+
107
  = 1.27 =
108
  * FIXED: Removing php short tags. ** Thanks Kailey Lampert! **
109
 
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.27
9
  Text Domain: wpmandrill
10
  */
11
  /* Copyright 2012 MailChimp (email : will@mailchimp.com )
@@ -1814,6 +1814,8 @@ JS;
1814
  // Letting the user filter/change the message payload
1815
  $message = apply_filters('mandrill_payload', $message);
1816
 
 
 
1817
  // Setting the tags property correctly to be received by the Mandrill's API
1818
  if ( !is_array($message['tags']['user']) ) $message['tags']['user'] = array();
1819
  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.28
9
  Text Domain: wpmandrill
10
  */
11
  /* Copyright 2012 MailChimp (email : will@mailchimp.com )
1814
  // Letting the user filter/change the message payload
1815
  $message = apply_filters('mandrill_payload', $message);
1816
 
1817
+ if ( isset($message['force_native']) && $message['force_native'] ) throw new Exception('Manually falling back to native wp_mail()');
1818
+
1819
  // Setting the tags property correctly to be received by the Mandrill's API
1820
  if ( !is_array($message['tags']['user']) ) $message['tags']['user'] = array();
1821
  if ( !is_array($message['tags']['general']) ) $message['tags']['general'] = array();