Right now there's no way to alter Mandrill messages to include/edit things like Mandrill metadata or tags.

This was also requested in #1661350: Allow more customization of message from drupal_mail but not added (instead that issue added support for file attachments).

CommentFileSizeAuthor
#1 1748234-1-mandrill_mail_alter.patch442 bytesfenstrat

Comments

fenstrat’s picture

Status: Active » Needs review
StatusFileSize
new442 bytes

Attached adds a simple drupal_alter() right before the message is sent.

pal4life’s picture

What is this patch about? Pardon my naivety.

fenstrat’s picture

@pal4life No worries, this allows modules to implement hook_mandrill_mail_alter() and alter any message parameters in $mandrill_message before sending.

/**
 * Implements hook_mandrill_mail_alter().
 */
function mymodule_mandrill_mail_alter(&$mandrill_message, $original_message) {
  $mandrill_message['metadata']['my_tracking_id'] = $original_message['my_tracking_id'];
}

That's a very simple example which inserts 'my_tracking_id' into metadata in the Mandrill message. You can then use this with Mandrill webhooks to process/track updates and use 'my_tracking_id' to uniquely identify which message the updates relate to.

levelos’s picture

Status: Needs review » Fixed

Thanks @fenstrat, committed.

fenstrat’s picture

Great, thanks @levelos.

Status: Fixed » Closed (fixed)

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

  • Commit 8967b2c on 7.x-1.x, 6.x-1.x, 7.x-2.x by levelos:
    #1748234: Allow altering of Mandrill messages.