I've got a custom template up on a site, but i'd like to use it just for a specific newsletter content type. I know that requires the use of a $mailkey reference, but I don't know how to implement that between the site and the tpl.php file.

Please assist. Thanks

Comments

sgabe’s picture

You can check the mailkey in the message source. Look for something like <body id="mimemail-body" class="mailkey-mail-simplenews-test">, mail-simplenews-test is the mailkey here. You can use mimemail-message--[mailkey].tpl.php for a specific mailkey.

sgabe’s picture

Status: Active » Closed (fixed)

Closing due to no response.

mottolini’s picture

I just want to add here a comment to help people find a solution to a severe documentation "bug"...

It's correct that you have to create a template file in the form mimemail-message--[mailkey].tpl.php, but you DON'T have to look at the class in the body tag for the generated html mail!
$mailkey value is changed in the function template_preprocess_mimemail_message (mimemail.theme.inc) with this line:

$variables['mailkey'] = 'mail-'. str_replace('_', '-', $variables['mailkey']);

So, you have to look for the real mailkey in the source code of the module creating that email or:

  1. try different variations: in my case I have class="mail-invite-invite" so my real mailkey could be "invite-invite" or "invite_invite"
  2. add in template_preprocess_mimemail_message a line before this above to save the real value of mailkey ($variables['mailkeyreal'] = $variables['mailkey'];)
Marko B’s picture

I am using views send, and mailkey there is not present. This is what I get class="mail-" mailkey should be a module creating mail as this way it seems we can't use this theming?

Marko B’s picture

From my testing so far the only difference between mailkey in body tag and mailkey needed for template is that in body you have
$mailkey which is mailkey-mail-simplenews-test and you only use simplenews-test, so in the end you have
mimemail-message--simplenews-test.tpl.php which is same logi as #3 said. So guess this is how mailkey should be used.