From 7c1ab91ebce8ce9d7dfd070156375369dbe42567 Mon Sep 17 00:00:00 2001 From: Steven Nguyen Date: Wed, 4 Oct 2023 16:53:38 -0700 Subject: [PATCH] Add support for variables in email template subject --- src/Appwrite/Platform/Workers/Mails.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Mails.php b/src/Appwrite/Platform/Workers/Mails.php index a29f2c6886..94a2a46087 100644 --- a/src/Appwrite/Platform/Workers/Mails.php +++ b/src/Appwrite/Platform/Workers/Mails.php @@ -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

tags, so use strip_tags() to remove them + $subject = \strip_tags($subjectTemplate->render()); + /** @var PHPMailer $mail */ $mail = empty($smtp) ? $register->get('smtp')