diff --git a/htmlmail.admin.inc b/htmlmail.admin.inc
index fcfea09..0d1ba07 100644
--- a/htmlmail.admin.inc
+++ b/htmlmail.admin.inc
@@ -184,6 +184,16 @@ function htmlmail_admin_settings() {
'#title' => t('Step 3'),
'#collapsible' => FALSE,
);
+ if (!module_exists('mailmime')) {
+ $form['filter']['htmlmail_html_with_plain'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Provide simple plain/text alternative of the HTML mail.'),
+ '#default_value' => variable_get('htmlmail_html_with_plain', FALSE),
+ '#description' => t('This may increase the quality of your outgoing emails for the spam filters. If you need image handling and more sophisticated plain text version, check !mailmime.', array(
+ '!mailmime' => l(t('Mailmime'), 'https://www.drupal.org/project/mailmime', array('attributes' => array('target' => '_blank'))),
+ ))
+ );
+ }
$form['filter']['htmlmail_postfilter'] = array(
'#type' => 'select',
'#title' => t('Post-filtering'),
diff --git a/htmlmail.mail.inc b/htmlmail.mail.inc
index 16fe7cd..b424cf1 100644
--- a/htmlmail.mail.inc
+++ b/htmlmail.mail.inc
@@ -120,6 +120,21 @@ class HTMLMailSystem implements MailSystemInterface {
else {
$message['headers']['Content-Type'] = 'text/html; charset=utf-8';
$message['body'] = $body;
+ if (variable_get('htmlmail_html_with_plain', FALSE)) {
+ $boundary = uniqid('np');
+ $message['headers']['Content-Type'] = "multipart/alternative;boundary=" . $boundary . "\r\n";
+ $html = $message['body'];
+ $raw_message = 'This is a MIME encoded message.';
+ $raw_message .= "\r\n\r\n--" . $boundary . "\r\n";
+ $raw_message .= "Content-type: text/plain;charset=utf-8\r\n\r\n";
+ $raw_message .= mailsystem_html_to_text($html);
+ $raw_message .= "\r\n\r\n--" . $boundary . "\r\n";
+ $raw_message .= "Content-type: text/html;charset=utf-8\r\n\r\n";
+ $raw_message .= $html;
+ $raw_message .= "\r\n\r\n--" . $boundary . "--";
+ $message['body'] = $raw_message;
+
+ }
}
}
else {