mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
add: custom senders for cloud.
This commit is contained in:
@@ -16,6 +16,9 @@ class Mail extends Event
|
||||
protected string $bodyTemplate = '';
|
||||
protected array $attachment = [];
|
||||
|
||||
protected string $senderEmail = '';
|
||||
protected string $senderName = '';
|
||||
|
||||
public function __construct(protected Publisher $publisher)
|
||||
{
|
||||
parent::__construct($publisher);
|
||||
@@ -400,6 +403,50 @@ class Mail extends Event
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set sender email
|
||||
*
|
||||
* @param string $email
|
||||
* @return self
|
||||
*/
|
||||
public function setSenderEmail(string $email): self
|
||||
{
|
||||
$this->senderEmail = $email;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sender email
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSenderEmail(): string
|
||||
{
|
||||
return $this->senderEmail;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set sender name
|
||||
*
|
||||
* @param string $name
|
||||
* @return self
|
||||
*/
|
||||
public function setSenderName(string $name): self
|
||||
{
|
||||
$this->senderName = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sender name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSenderName(): string
|
||||
{
|
||||
return $this->senderName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset
|
||||
*
|
||||
@@ -415,6 +462,8 @@ class Mail extends Event
|
||||
$this->variables = [];
|
||||
$this->bodyTemplate = '';
|
||||
$this->attachment = [];
|
||||
$this->senderEmail = '';
|
||||
$this->senderName = '';
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -436,6 +485,8 @@ class Mail extends Event
|
||||
'smtp' => $this->smtp,
|
||||
'variables' => $this->variables,
|
||||
'attachment' => $this->attachment,
|
||||
'senderEmail' => $this->senderEmail,
|
||||
'senderName' => $this->senderName,
|
||||
'events' => Event::generateEvents($this->getEvent(), $this->getParams())
|
||||
];
|
||||
}
|
||||
|
||||
@@ -152,7 +152,13 @@ class Mails extends Action
|
||||
$replyTo = System::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM);
|
||||
$replyToName = \urldecode(System::getEnv('_APP_SYSTEM_EMAIL_NAME', APP_NAME . ' Server'));
|
||||
|
||||
if (!empty($smtp)) {
|
||||
$senderEmail = $payload['senderEmail'] ?? '';
|
||||
$senderName = $payload['senderName'] ?? '';
|
||||
|
||||
if (!empty($senderEmail)) {
|
||||
$replyTo = $senderEmail;
|
||||
$replyToName = $senderName;
|
||||
} elseif (!empty($smtp)) {
|
||||
$replyTo = !empty($smtp['replyTo']) ? $smtp['replyTo'] : $smtp['senderEmail'];
|
||||
$replyToName = $smtp['senderName'];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user