diff --git a/src/Appwrite/Event/Mail.php b/src/Appwrite/Event/Mail.php index 47c9125c01..9973dae403 100644 --- a/src/Appwrite/Event/Mail.php +++ b/src/Appwrite/Event/Mail.php @@ -13,6 +13,7 @@ class Mail extends Event protected string $body = ''; protected array $smtp = []; protected array $variables = []; + protected string $bodyTemplate = ''; protected array $attachment = []; public function __construct(protected Connection $connection) @@ -116,6 +117,29 @@ class Mail extends Event return $this->name; } + /** + * Sets bodyTemplate for the mail event. + * + * @param string $bodyTemplate + * @return self + */ + public function setbodyTemplate(string $bodyTemplate): self + { + $this->bodyTemplate = $bodyTemplate; + + return $this; + } + + /** + * Returns subject for the mail event. + * + * @return string + */ + public function getbodyTemplate(): string + { + return $this->bodyTemplate; + } + /** * Set SMTP Host * @@ -344,6 +368,7 @@ class Mail extends Event 'recipient' => $this->recipient, 'name' => $this->name, 'subject' => $this->subject, + 'bodyTemplate' => $this->bodyTemplate, 'body' => $this->body, 'smtp' => $this->smtp, 'variables' => $this->variables, diff --git a/src/Appwrite/Platform/Workers/Mails.php b/src/Appwrite/Platform/Workers/Mails.php index 9018f219ae..8c1e3c2ec8 100644 --- a/src/Appwrite/Platform/Workers/Mails.php +++ b/src/Appwrite/Platform/Workers/Mails.php @@ -60,8 +60,11 @@ class Mails extends Action $name = $payload['name']; $body = $payload['body']; $attachment = $payload['attachment'] ?? []; - - $bodyTemplate = Template::fromFile(__DIR__ . '/../../../../app/config/locale/templates/email-base.tpl'); + $bodyTemplate = $payload['bodyTemplate']; + if (empty($bodyTemplate)) { + $bodyTemplate = __DIR__ . '/../../../../app/config/locale/templates/email-base.tpl'; + } + $bodyTemplate = Template::fromFile($bodyTemplate); $bodyTemplate->setParam('{{body}}', $body); foreach ($variables as $key => $value) { $bodyTemplate->setParam('{{' . $key . '}}', $value);