Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-12116

MailTemplates->sendTemplate uses tokens from plaintext email in subject

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 4.2.8
    • Fix Version/s: Unscheduled
    • Component/s: Core CiviCRM
    • Labels:
      None
    • Versioning Impact:
      Patch (backwards-compatible bug fixes)

      Description

      If someone tries using a token in the mail subject that isn't used in the plain text version of the email, the token is rendered as blank. Although this is an unlikely scenario, it's still possible that someone may need this.

      The structure of the token replacement logic in CRM_Core_BAO_MessageTemplates::sendTemplate() uses the tokens loaded in to the plain text version of the subject.

      This is recognised in the comment on line 393 of CRM/Core/BAO/MessageTemplates.php: // replace tokens in the three elements (in subject as if it was the text body).

      On line 396, CRM_Mailing_BAO_Mailing::getTokens() returns an array that has a slot for "subject", however in line 430 and 435, CRM_Utils_Token::replaceContactTokens is using $tokens['text'] rather than $tokens['subject']. We would need to define the subject in the CRM_Mailing_BAO_Mailing object just before line 396 (where $mailing->body_text and $mailing->body_html are set), but this seems relatively straightforward.

      If this has been reported already, please close. Otherwise, I'm happy to look at submitting a patch for consideration.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              jamesinglis James Inglis
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: