diff --git a/mailmime.inc b/mailmime.inc
index 9700724..a8ae9c9 100644
--- a/mailmime.inc
+++ b/mailmime.inc
@@ -779,14 +779,17 @@ class MailMIME extends Mail_mime {
       )->headers;
     }
     foreach ($input as $name => $value) {
+      $name = preg_replace_callback(
+          '/([[:alpha:]])([[:alpha:]]+)/',
+          create_function('$matches', 'return strtoupper($matches[1]) . strtolower($matches[2]);'),
+        $name
+      );
       $name = preg_replace(
         array(
-          '/([[:alpha:]])([[:alpha:]]+)/e',
           '/^Mime-/',
           '/-Id$/',
         ),
         array(
-          'strtoupper("\1") . strtolower("\2")',
           'MIME-',
           '-ID',
         ),
