$mailParams = [
'groupName' => 'Scheduled Reminder Sender',
'from' => self::pickFromEmail($schedule),
- 'toName' => $tokenRow->context['contact']['display_name'],
+ 'toName' => $tokenRow->render('toName'),
'toEmail' => $toEmail,
'subject' => $tokenRow->render('subject'),
'entity' => 'action_schedule',
'entity_id' => $schedule->id,
];
- if (!$body_html || $tokenRow->context['contact']['preferred_mail_format'] === 'Text' ||
- $tokenRow->context['contact']['preferred_mail_format'] === 'Both'
+ $preferredMailFormat = $tokenRow->render('preferred_mail_format');
+ if (!$body_html || $preferredMailFormat === 'Text' || $preferredMailFormat === 'Both'
) {
// render the & entities in text mode, so that the links work
$mailParams['text'] = str_replace('&', '&', $body_text);
$tp->addMessage('body_html', $schedule->body_html, 'text/html');
$tp->addMessage('sms_body_text', $schedule->sms_body_text, 'text/plain');
$tp->addMessage('subject', $schedule->subject, 'text/plain');
+ // These 2 are not 'real' tokens - but it tells the processor to load them.
+ $tp->addMessage('toName', '{contact.display_name}', 'text/plain');
+ $tp->addMessage('preferred_mail_format', '{contact.preferred_mail_format}', 'text/plain');
+
return $tp;
}
);
foreach ($hookTokens as $hookToken) {
foreach ($messageTokens[$hookToken] as $tokenName) {
- $row->format('text/plain')->tokens($hookToken, $tokenName, $contactArray[$row->context['contactId']][$tokenName] ?? '');
+ $row->tokens($hookToken, $tokenName, $contactArray[$row->context['contactId']]["{$hookToken}.{$tokenName}"] ?? '');
}
}
}