Issue:

Mimemail's use of token_replace in mimemail.module is such that if a token does not contain a replacement value, the token name is still spat out in the email.

Solution:

token_replace is defined as token_replace($text, array $data = array(), array $options = array()).
In the options aray, there is a 'clear' option which is "A boolean flag indicating that tokens should be removed from the final text if no replacement value can be generated."

I simply added this 'clear' option to all instances of token_replace() within mimemail.module, and in my test case it works as expected: No tokens in the email :)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

obarillet’s picture

An alternative solution is provided here: http://drupal.org/node/1559844#comment-6055722
It's a patch that applies to the Rules module itself and providing the same fix.

fullerja’s picture

This doesn't get along well with Webform Conditionals. I think the issue is that when a field is not shown to the user, it is not in the submission as NULL, so the token is still rendered. Is there a way to tweak the logic so that that if a value is not found the token is not rendered rather than if the value is NULL the token is not rendered?

sgabe’s picture

Title: Tokens should be removed if no replacement value can be generated. » Remove tokens if no replacement value can be generated
Status: Needs review » Fixed
FileSize
1.53 KB

The attached patch has been committed.

Status: Fixed » Closed (fixed)

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