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? Commented Dec 29, 2017 at 12:50
  • @PradeepNayak - sorry - edited the post now
    – commonpike
    Commented Dec 30, 2017 at 20:14

2 Answers 2


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
    Commented Jan 1, 2018 at 14:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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