Merge pull request #7251 from appwrite/feat-mail-template-override-ur
This commit is contained in:
commit
1836e89dff
|
@ -13,6 +13,7 @@ class Mail extends Event
|
||||||
protected string $body = '';
|
protected string $body = '';
|
||||||
protected array $smtp = [];
|
protected array $smtp = [];
|
||||||
protected array $variables = [];
|
protected array $variables = [];
|
||||||
|
protected string $bodyTemplate = '';
|
||||||
protected array $attachment = [];
|
protected array $attachment = [];
|
||||||
|
|
||||||
public function __construct(protected Connection $connection)
|
public function __construct(protected Connection $connection)
|
||||||
|
@ -116,6 +117,29 @@ class Mail extends Event
|
||||||
return $this->name;
|
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
|
* Set SMTP Host
|
||||||
*
|
*
|
||||||
|
@ -344,6 +368,7 @@ class Mail extends Event
|
||||||
'recipient' => $this->recipient,
|
'recipient' => $this->recipient,
|
||||||
'name' => $this->name,
|
'name' => $this->name,
|
||||||
'subject' => $this->subject,
|
'subject' => $this->subject,
|
||||||
|
'bodyTemplate' => $this->bodyTemplate,
|
||||||
'body' => $this->body,
|
'body' => $this->body,
|
||||||
'smtp' => $this->smtp,
|
'smtp' => $this->smtp,
|
||||||
'variables' => $this->variables,
|
'variables' => $this->variables,
|
||||||
|
|
|
@ -60,8 +60,11 @@ class Mails extends Action
|
||||||
$name = $payload['name'];
|
$name = $payload['name'];
|
||||||
$body = $payload['body'];
|
$body = $payload['body'];
|
||||||
$attachment = $payload['attachment'] ?? [];
|
$attachment = $payload['attachment'] ?? [];
|
||||||
|
$bodyTemplate = $payload['bodyTemplate'];
|
||||||
$bodyTemplate = Template::fromFile(__DIR__ . '/../../../../app/config/locale/templates/email-base.tpl');
|
if (empty($bodyTemplate)) {
|
||||||
|
$bodyTemplate = __DIR__ . '/../../../../app/config/locale/templates/email-base.tpl';
|
||||||
|
}
|
||||||
|
$bodyTemplate = Template::fromFile($bodyTemplate);
|
||||||
$bodyTemplate->setParam('{{body}}', $body);
|
$bodyTemplate->setParam('{{body}}', $body);
|
||||||
foreach ($variables as $key => $value) {
|
foreach ($variables as $key => $value) {
|
||||||
$bodyTemplate->setParam('{{' . $key . '}}', $value);
|
$bodyTemplate->setParam('{{' . $key . '}}', $value);
|
||||||
|
|
Loading…
Reference in a new issue