--- simplenews/simplenews.module.ORIGINAL 2008-09-20 13:40:28.000000000 +0200
+++ simplenews/simplenews.module 2008-09-20 16:00:33.000000000 +0200
@@ -1338,9 +1338,29 @@
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)));
+ }
}
}
}
@@ -1452,7 +1472,6 @@
$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
@@ -1484,6 +1503,9 @@
$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)) .'>';
@@ -1576,10 +1598,33 @@
$params['context']['node'] = $node;
// Send mail
- $message = drupal_mail('simplenews', 'node', $subscription->mail, $subscription->language, $params, $params['from']['address'], TRUE);
+ 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', '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);
+ 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.