diff --git a/includes/phpmailer.mimemail.inc b/includes/phpmailer.mimemail.inc
index ccac3bf..e5f3679 100644
--- a/includes/phpmailer.mimemail.inc
+++ b/includes/phpmailer.mimemail.inc
@@ -30,6 +30,9 @@ function mimemail_phpmailer_send($message) {
     $mail->From = $from['mail'];
     if ($from['name'] != '') {
       $mail->FromName = $from['name'];
+      if (variable_get('smtp_encode_headers') && preg_match('/\=\?UTF-8\?B\?.*\?\=/', $from['name']) === 0) {
+        $mail->FromName = mime_header_encode($from['name']);
+      }
     }
 
     if (variable_get('phpmailer_debug_email', '') === '') {
@@ -69,6 +72,9 @@ function mimemail_phpmailer_send($message) {
     }
 
     $message['headers']['Subject'] = $message['subject'];
+    if (variable_get('smtp_encode_headers') && preg_match('/\=\?UTF-8\?B\?.*\?\=/', $message['subject']) === 0) {
+      $message['headers']['Subject'] = mime_header_encode($message['subject']);
+    }
 
     // FIXME SpamAssassin says INVALID_MSGID to PHPMailer's generated Message-ID. 06/04/2009 smk
 //    if (!isset($message['headers']['Message-ID'])) {
@@ -85,4 +91,3 @@ function mimemail_phpmailer_send($message) {
     return FALSE;
   }
 }
-
diff --git a/phpmailer.admin.inc b/phpmailer.admin.inc
index 3b39542..b101525 100644
--- a/phpmailer.admin.inc
+++ b/phpmailer.admin.inc
@@ -136,6 +136,12 @@ function phpmailer_settings_form($form, $form_state) {
     '#default_value' => variable_get('smtp_keepalive', 0),
     '#description' => t('Whether to reuse an existing connection during a request.  Improves performance when sending a lot of e-mails at once.'),
   );
+  $form['advanced']['smtp_encode_headers'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Encode headers'),
+    '#default_value' => variable_get('smtp_encode_headers', 0),
+    '#description' => t('If you have subjects and names with accented, etc. characters, check this box to UTF-8 encode them before sending the message.'),
+  );
   $form['advanced']['smtp_debug'] = array(
     '#type' => 'select',
     '#title' => t('Debug level'),
@@ -344,4 +350,3 @@ function phpmailer_preview() {
   print $body;
   drupal_exit();
 }
-
