Hi,

I use Mail System + Mime Mail + SMTP Authentication Support + Mandrill (SMTP) successfully since lot of time now.

I've upgraded Mime Mail from version 7.x-1.0-beta3 to 7.x-1.0-beta4 and since that, all my previously working HTML email are now received as undecoded base64 encoded string in emails clients.

I've searched and tried a lot of things, and it seems to be because of bad Content-Transfer-Encoding before base64 encoded part of email.

Here is a snippet of a dump of email in mimemail module function

This is a multi-part message in MIME format. 
--ad0177a045eb126a3e144e6fba5179a0198fb3761 
Content-Type: multipart/alternative; boundary="2748746a42d9e843db737836c6d60f7e2e46f1670" 
Content-Transfer-Encoding: 8bit 
--2748746a42d9e843db737836c6d60f7e2e46f1670 
Content-Type: text/plain; charset=utf-8 
Content-Disposition: inline 
Content-Transfer-Encoding: 8bit 

======== text mail ===

--2748746a42d9e843db737836c6d60f7e2e46f1670 
Content-Type: text/html; charset=utf-8 
Content-Disposition: inline 
Content-Transfer-Encoding: base64 

PCFET0NUWVBFIGh0bWwgUFVCTElDICItLy9XM0MvL0RURCBIVE1MIDQuMCBUcmFuc2l0aW9uYWwv(...) 

--2748746a42d9e843db737836c6d60f7e2e46f1670-- 
--ad0177a045eb126a3e144e6fba5179a0198fb3761--

What's going wrong ?

Thanks

Comments

rroblik created an issue. See original summary.

nwehner’s picture

I use Mandrill as well, but with PHP Mailer - it works fine that way for me.

rroblik’s picture

@nwehner Thanks but SMTP Authentication Support do the delivery job well (PHPMailer (Drupal module) is about the same as SMTP Authentication Support, I've just tried that)

The problem is in Mime Mail, that's why I opened a issue here :)

Regards

wundo’s picture

I use SMTP module + Mandrill and works great as well.

deepbluesolutions’s picture

Were seeing this issue as well, when using SimpleNews dev , Smtp dev and MimeMail beta4, reverting to MimeMail Beta 3 restored the correct encoding on the output. The issue is also shown when using mandrill instead of smtp.

janton’s picture

We've issues as well and will revert back to beta3.
We get errors from mandrill that all body mails are empty ?
Also we see some strange attachment.dat file with no SMTP mails.

We've exactly the same setup:
Mail System + Mime Mail + SMTP Authentication Support + Mandrill

weseze’s picture

You can work arround this issue by implementing your own mimemail engine in a custom module:

/**
 * Mimemail prepare message override function.
 * Default mimemail engine does not play well with the how Mandrill mail system
 * expects the body of the message. Reset the message body to the original body,
 * ignoring all mimemails logic for handling plain text alternatives. Mandrill
 * will handle that.
 * @see: mimemail.module (line 356-378) function mimemail_prepare_message().
 */
function YOUR_CUSTOM_MODULE_prepare_message($message) {
  // Let mimemail handle the message as at normally does.
  $new_message = mimemail_prepare_message($message);

  // Reprocess the body generation.
  $hook = array(
    'mimemail_message__' . $new_message['key'],
    'mimemail_message__' . $new_message['module'] .'__'. $new_message['key'],
  );
  $variables = array(
    'module' => $new_message['module'],
    'key' => $new_message['key'],
    'recipient' => $new_message['to'],
    'subject' => $new_message['subject'],
    'body' => $message['body'],
  );
  $body = theme($hook, $variables);
  foreach (module_implements('mail_post_process') as $module) {
    $function = $module . '_mail_post_process';
    $function($body, $message['key']);
  }
  $new_message['body'] = $body;

  return $new_message;
}

/**
 * Implements hook_mailengine().
 */
function YOUR_CUSTOM_MODULE_mailengine($op, $message = array()) {
  module_load_include('inc', 'mimemail');

  if ($op == 'list') {
    return array(
      'name' => t('Mandrill compatible engine'),
    );
  }

  return mimemail_mailengine($op, $message);
}

After enabling this module, visit /admin/config/system/mimemail and there should be an extra setting at the bottom now called "E-mail engine". Select "Mandrill compatible engine" and hit "Save configuration". That's it.

It's far from an ideal (or correct) solution so feel free to give feedback.

blart’s picture

The problem was in #2404719. Reverting the patch has fixed this issue for us with Mail System + Mime Mail + SMTP Authentication Support + Mandrill setup.

TR’s picture

Status: Active » Closed (works as designed)

Yes, Mandrill tries to do some of the same mail formatting that is done by Mime Mail. See #2955538: Multi-part message in Mimemall for an explanation. There are issues in the Mandrill queue which address this, start with #1863988: Mail System HTML Email issue with: MimeMailSystem_MandrillMailSystem.

Mime Mail formats the message, it does nothing about sending. Mandrill mixes formatting and sending. I think there's always going to be some clash between Mime Mail and Mandrill until Mandrill separates its formatting from its sending - otherwise Mandrill can't be used with any other mail system module.