Answers.Body: <p>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 <a href="https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_tokens/" rel="nofollow noreferrer">tokens</a> and <a href="https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_tokenValues/" rel="nofollow noreferrer">tokenValues</a> hooks to have {domain.xxx} work.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-01T14:19:20.687Z
Answers.Text: I did sort of the same, but now the domain* values are configured in two places :-/
Answers.UserDisplayName: commonpike
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-01T07:02:41.870Z
Answers.LastActivityDate: 2018-01-01T07:02:41.870Z
Answers.UserDisplayName: Freelance User
Answers.Body: <p>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.</p>
  
  <pre><code>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);
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-31T12:33:47.733Z
Answers.Text: do you know if this is already in the bugtracker ? i can add it.
Answers.UserDisplayName: commonpike
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-31T12:57:55.923Z
Answers.Text: No, this is not logged in CiviCRM issue tracker. Please go ahead and log.
Answers.UserDisplayName: Pradeep Nayak
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-01T14:16:31.723Z
Answers.Text: Thank, did that here https://issues.civicrm.org/jira/browse/CRM-21615
Answers.UserDisplayName: commonpike
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-31T11:06:31.337Z
Answers.LastActivityDate: 2017-12-31T11:06:31.337Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>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 ?</p>
  
  <p>If it isn't me, then the documentation here is wrong ?
  <a href="https://docs.civicrm.org/user/en/latest/common-workflows/tokens-and-mail-merge/#domainaddress" rel="nofollow noreferrer">https://docs.civicrm.org/user/en/latest/common-workflows/tokens-and-mail-merge/#domainaddress</a></p>
  
  <p>Drupal 7.56, CiviCRM 4.7.27</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-12-29T12:50:12.663Z
Comments.Text: Which version of CiviCRM are you using and CMS?
Comments.UserDisplayName: Pradeep Nayak
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-12-30T20:14:24.527Z
Comments.Text: @PradeepNayak - sorry - edited the post now
Comments.UserDisplayName: commonpike
Tags: <drupal><email><tokens>
Title: {domain...} tokens not parsed in regular mail?
ThreadText: # {domain...} tokens not parsed in regular mail?
  
  (Asked by: username_0 on 2017-12-29)
  
  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
  
  **Tags:** drupal, email, tokens
  
  > **Comments:**
  > **username_1**: Which version of CiviCRM are you using and CMS?  
  > **username_0**: @PradeepNayak - sorry - edited the post now  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2017-12-31. Score: 4 | Accepted answer
  
  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);
  
  > **Comments:**
  > **username_0**: do you know if this is already in the bugtracker ? i can add it.  
  > **username_1**: No, this is not logged in CiviCRM issue tracker. Please go ahead and log.  
  > **username_0**: Thank, did that here https://issues.civicrm.org/jira/browse/CRM-21615  
  
  ---
  
  ### Answer by username_2 on 2018-01-01. Score: 1
  
  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](https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_tokens/) and [tokenValues](https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_tokenValues/) hooks to have {domain.xxx} work.
  
  > **Comments:**
  > **username_0**: I did sort of the same, but now the domain* values are configured in two places :-/  
  
  ---
  
  