1
0
Fork 0
mirror of synced 2024-07-03 13:41:01 +12:00

Add support for variables in email template subject

This commit is contained in:
Steven Nguyen 2023-10-04 16:53:38 -07:00
parent fc4fa977a0
commit 7c1ab91ebc
No known key found for this signature in database

View file

@ -62,13 +62,18 @@ class Mails extends Action
$bodyTemplate = Template::fromFile(__DIR__ . '/../../../../app/config/locale/templates/email-base.tpl');
$bodyTemplate->setParam('{{body}}', $body);
foreach ($variables as $key => $value) {
$bodyTemplate->setParam('{{' . $key . '}}', $value);
}
$body = $bodyTemplate->render();
$subjectTemplate = Template::fromString($subject);
foreach ($variables as $key => $value) {
$subjectTemplate->setParam('{{' . $key . '}}', $value);
}
// render() will return the subject in <p> tags, so use strip_tags() to remove them
$subject = \strip_tags($subjectTemplate->render());
/** @var PHPMailer $mail */
$mail = empty($smtp)
? $register->get('smtp')