Is it me, or are the {domain...} tokens not parsed in a private (non-civimail) mail ? Like, when sending a mail from a contacts page ?

If it isn't me, then the documentation here is wrong ? https://docs.civicrm.org/user/en/latest/common-workflows/tokens-and-mail-merge/#domainaddress

Drupal 7.56, CiviCRM 4.7.27

  • Which version of CiviCRM are you using and CMS? Dec 29 '17 at 12:50
  • @PradeepNayak - sorry - edited the post now
    – commonpike
    Dec 30 '17 at 20:14

Domain tokens are not replaced when trying to send email activity for a contact. This seems like a bug in civicrm or wrong documentation. This can be fixed by applying below patch.

diff --git a/CRM/Activity/BAO/Activity.php b/CRM/Activity/BAO/Activity.php
index 787a1c955d..35133010e1 100644
--- a/CRM/Activity/BAO/Activity.php
+++ b/CRM/Activity/BAO/Activity.php
@@ -1587,6 +1587,12 @@ LEFT JOIN civicrm_activity_contact src ON (src.activity_id = ac.activity_id AND
         $values = array_merge($values, $details["{$contactId}"]);

+      $domainTokens = array_merge($subjectToken, $messageToken);
+      $domain = CRM_Core_BAO_Domain::getDomain();
+      foreach (['subject', 'text', 'html'] as $bodyType) {
+        $$bodyType = CRM_Utils_Token::replaceDomainTokens($$bodyType, $domain, TRUE, $domainTokens, TRUE);
+      }
       $tokenSubject = CRM_Utils_Token::replaceContactTokens($subject, $values, FALSE, $subjectToken, FALSE, $escapeSmarty);
       $tokenSubject = CRM_Utils_Token::replaceHookTokens($tokenSubject, $values, $categories, FALSE, $escapeSmarty);

I believe this is a missing feature is core. The documentation do suggest that custom tokens can be used in non-bulk mailings. However, tokens like actions, mailings are not replaced. One of our client wanted to have domain details send in non-bulk emails, we used tokens and tokenValues hooks to have {domain.xxx} work.

  • I did sort of the same, but now the domain* values are configured in two places :-/
    – commonpike
    Jan 1 '18 at 14:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.