diff -urp 6.x-1.x-dev/simplenews/simplenews.module 6.x-1.x-dev-patched/simplenews/simplenews.module --- 6.x-1.x-dev/simplenews/simplenews.module 2008-09-01 10:51:33.000000000 -0400 +++ 6.x-1.x-dev-patched/simplenews/simplenews.module 2008-09-12 16:49:19.000000000 -0400 @@ -1336,9 +1336,29 @@ function simplenews_send_test($node, $ac foreach ($accounts as $account) { $subscription = simplenews_get_subscription($account); $params['context']['account'] = $subscription; - $result = drupal_mail('simplenews', 'test', $account->mail, $subscription->language, $params, $from['address']); - if ($result['result']) { - drupal_set_message(t('Test newsletter sent to %recipient.', array('%recipient' => $account->mail))); + if (module_exists('mimemail')) { + $message = drupal_mail('simplenews', 'test', $account->mail, $subscription->language, $params, $from['formatted'], FALSE); + $plain = $message['params']['context']['node']->simplenews['s_format'] === 'plain'; + if (mimemail( + $message['from'], + $message['to'], + $message['subject'], + $message['body'], + $plain, + $message['headers'], + $plain ? $message['body'] : simplenews_html_to_text($message['body']), + isset($message['params']['context']['node']->files) ? $message['params']['context']['node']->files : array(), + '', + FALSE + )) { + drupal_set_message(t('Test newsletter sent to %recipient.', array('%recipient' => $account->mail))); + } + } + else { + $result = drupal_mail('simplenews', 'test', $account->mail, $subscription->language, $params, $from['address']); + if ($result['result']) { + drupal_set_message(t('Test newsletter sent to %recipient.', array('%recipient' => $account->mail))); + } } } } @@ -1450,7 +1470,6 @@ function simplenews_mail($key, &$message $node->body = $content; unset($node->teaser); node_invoke_nodeapi($node, 'alter', FALSE, TRUE); - $node = node_prepare($node); $body = theme('simplenews_newsletter_body', $node->body, check_plain($node->title), $message['language']); // Buffer body text node and language specific @@ -1482,6 +1501,9 @@ function simplenews_mail($key, &$message $hash = ''; } $message['body']['footer'] = theme('simplenews_newsletter_footer', $context['node']->simplenews['s_format'], $hash, $key == 'test', $message['language']); + if ($context['node']->simplenews['s_format'] === 'plain') { + $message['body']['footer'] = simplenews_html_to_text($message['body']['footer']); + } // Add user specific header data. $message['headers']['List-Unsubscribe'] = '<'. url('newsletter/confirm/remove/'. $hash, array('absolute' => TRUE)) .'>'; @@ -1574,14 +1596,37 @@ function simplenews_mail_send($nid = NUL $params['context']['node'] = $node; // Send mail - $message = drupal_mail('simplenews', 'node', $subscription->mail, $subscription->language, $params, $params['from']['address'], TRUE); - - if (variable_get('simplenews_debug', FALSE)) { - watchdog('simplenews', 'Outgoing email. Message type: %type
Subject: %subject
Recipient: %to', array('%type' => 'node', '%to' => $message['to'], '%subject' => $message['subject']), WATCHDOG_DEBUG); + if (module_exists('mimemail')) { + $message = drupal_mail('simplenews', 'node', $subscription->mail, $subscription->language, $params, $params['from']['formatted'], FALSE); + $plain = $message['params']['context']['node']->simplenews['s_format'] === 'plain'; + // Succesful mailings are recorded with their spool id. + if (mimemail( + $message['from'], + $message['to'], + $message['subject'], + $message['body'], + $plain, + $message['headers'], + $plain ? $message['body'] : simplenews_html_to_text($message['body']), + isset($message['params']['context']['node']->files) ? $message['params']['context']['node']->files : array(), + '' + )) { + $mail_sent[] = $key; + } + if (variable_get('simplenews_debug', FALSE)) { + watchdog('simplenews', t('Outgoing email via Mime Mail. Message type: %type
Subject: %subject
Recipient: %to', array('%type' => 'node', '%to' => $message['to'], '%subject' => $message['subject'])), WATCHDOG_DEBUG); + } + } + else { + $message = drupal_mail('simplenews', 'node', $subscription->mail, $subscription->language, $params, $params['from']['address'], TRUE); + + if (variable_get('simplenews_debug', FALSE)) { + watchdog('simplenews', 'Outgoing email. Message type: %type
Subject: %subject
Recipient: %to', array('%type' => 'node', '%to' => $message['to'], '%subject' => $message['subject']), WATCHDOG_DEBUG); + } } - // Succesfull mail messages are marked in the spool with status send. - // Succesfull mail are recorded with their spool id. + // Succesful mail messages are marked in the spool with status send. + // Succesful mailings are recorded with their spool id. if ($message['result']) { $mail_sent[] = $key; }