--- simplenews.module	2007-02-10 19:18:46.000000000 +0100
+++ simplenews.31524.module	2007-02-10 14:26:26.000000000 +0100
@@ -1136,6 +1136,21 @@ function simplenews_mail_confirm($email,
  *   An object with at least $mail->to, $mail->subject, and $mail->message.
  */
 function simplenews_mail_send($mail) {
+    // If enabled perform base64 encoding on long text string
+    $content_transfer = '8Bit';
+    if ($mail->s_format == 'html' && variable_get('simplenews_base64_encode', 0)) {
+      $body = split("\n", $mail->body);
+      foreach ($body as $line) {
+        if (strlen($line) > 998) {
+          $content_transfer = 'base64';
+          break;
+        }
+      }
+      if ($content_transfer == 'base64') {
+        $mail->body = rtrim(chunk_split(base64_encode($mail->body)));
+      }
+    }
+    
   $from_email = isset($mail->from_address) ? $mail->from_address : variable_get('site_mail', ini_get('sendmail_from'));
   $from = isset($mail->from_name) ? '"'. addslashes($mail->from_name).'" <'. $from_email .'>' : $from_email;
 
@@ -1145,6 +1160,7 @@ function simplenews_mail_send($mail) {
     'X-Mailer' => 'Drupal',
     'Return-Path' => $from_email,
     'Errors-To' => $from_email,
+    'Content-Transfer-Encoding' => $content_transfer,
   );
 
   // If receipt is requested, add headers.
@@ -1886,6 +1902,12 @@ function simplenews_admin_settings($tid 
       '#options' => array(0 => t("Don't send now"), 2 => t('Send one test newsletter to the test address'), 1 => t('Send newsletter')),
       '#default_value' => variable_get('simplenews_send', 0),
     );
+    $form['simplenews_default_options']['simplenews_base64_encode'] = array('#type' => 'checkbox',
+      '#title' => t('Base64 encoding'),
+      '#return_value' => 1,
+      '#default_value' => variable_get('simplenews_base64_encode', 0),
+      '#description' => t('Performs Base64 encoding of html text when long strings are used. Use this option if you experience problems with question marks being inserted into your mail because of too long lines (999 characters and more).'),
+    );
     $form['simplenews_test_address'] = array('#type' => 'fieldset',
       '#title' => t('Test addresses options'),
       '#collapsible' => TRUE,
