Hi,

I found that mail logger modifies the emails by other modules in a way that mail clients can not open attachments anymore.

Initially I reported this problem of wrong attachments to the "mass contact" maintainer (http://drupal.org/node/367313) but after some tests I found that attachments fail only with enabled mail logger. As soon as I disable mail logger, the received attachments are ok again.

Thanks,
Ulf

CommentFileSizeAuthor
#5 mail_logger_do_not_change_mail.patch754 bytesmokko

Comments

litwol’s picture

Status: Active » Postponed (maintainer needs more info)

Can you debug what exactly is breaking email attachments?

ulf1’s picture

No, I have not debugged into Mail logger, but from looking into the code it is pretty obvious what causes the problem.

In function mail_logger_mail_alter(&$message),

the message body itself is being modified to prepare it for the mail_logger table.

$message['body'] = is_array($message['body']) ? drupal_wrap_mail(implode("\n\n", $message['body'])) : drupal_wrap_mail($message['body']);

I am pretty sure that if the code would work with a copy of the message body it will work:

$logger_message['body'] = is_array($message['body']) ? drupal_wrap_mail(implode("\n\n", $message['body'])) : drupal_wrap_mail($message['body']);
$args = array(
$message['id'],
$message['to'],
$message['subject'],
$logger_message['body'],
$message['from'],
serialize($message['headers']),
time(),
$message['language']->language,
);

instead of

$message['body'] = is_array($message['body']) ? drupal_wrap_mail(implode("\n\n", $message['body'])) : drupal_wrap_mail($message['body']);
$args = array(
$message['id'],
$message['to'],
$message['subject'],
$message['body'],
$message['from'],
serialize($message['headers']),
time(),
$message['language']->language,
);

~
Ulf

ulf1’s picture

Status: Postponed (maintainer needs more info) » Active
mokko’s picture

Since the purpose is to log emails and NOT to change them, I suggest to not to use a reference in mail_logger_mail_alter so that we are safe.

mokko’s picture

Version: 6.x-1.0 » 6.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new754 bytes

  • Commit 322b6ac on 6.x-1.x by fizk:
    #388164 mokko: Avoid modifying the original message in...
fizk’s picture

Issue summary: View changes
Status: Needs review » Fixed

Fixed, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.