From abddee55e13f93325b59e8a54e5dddc514e0eed1 Mon Sep 17 00:00:00 2001
From: Fabian Franz <ffranz@trellon.com>
Date: Fri, 11 Nov 2011 18:44:29 +0000
Subject: [PATCH] Issue #1199966 by pillarsdotnet: The Content-Type header is incorrectly parsed in SmtpMailSystem::mail() function.

---
 smtp.mail.inc |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/smtp.mail.inc b/smtp.mail.inc
index 5acd53f..a053187 100644
--- a/smtp.mail.inc
+++ b/smtp.mail.inc
@@ -152,11 +152,11 @@ class SmtpMailSystem implements MailSystemInterface {
         case 'content-type':
           // Parse several values on the Content-type header, storing them in an array like
           // key=value -> $vars['key']='value'
-          $vars = explode('; ', $value);
+          $vars = explode(';', $value);
           foreach ($vars as $i => $var) {
             if ($cut = strpos($var, '=')) {
-              $new_var = drupal_strtolower(drupal_substr($var, $cut + 1));
-              $new_key = drupal_substr($var, 0, $cut);
+              $new_var = trim(drupal_strtolower(drupal_substr($var, $cut + 1)));
+              $new_key = trim(drupal_substr($var, 0, $cut));
               unset($vars[$i]);
               $vars[$new_key] = $new_var;
             }
@@ -198,8 +198,8 @@ class SmtpMailSystem implements MailSystemInterface {
             break;
             default:
               // Everything else is unsuppored by PHPMailer.
-              drupal_set_message(t('The Content-Type of your message is not supported by PHPMailer and will be sent as text/plain instead.'), 'error');
-              watchdog('smtp', 'The Content-Type of your message is not supported by PHPMailer and will be sent as text/plain instead.', array(), WATCHDOG_ERROR);
+              drupal_set_message(t('The %header of your message is not supported by PHPMailer and will be sent as text/plain instead.', array('%header' => "Content-Type: $value")), 'error');
+              watchdog('smtp', 'The %header of your message is not supported by PHPMailer and will be sent as text/plain instead.', array('%header' => "Content-Type: $value"), WATCHDOG_ERROR);
 
               // Force the Content-Type to be text/plain.
               $mailer->IsHTML(FALSE);
-- 
1.7.0.4

