add: custom senders for cloud.

This commit is contained in:
Darshan
2025-12-10 14:32:04 +05:30
parent bdfb9e305e
commit b03aa8d632
2 changed files with 58 additions and 1 deletions
+51
View File
@@ -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())
];
}
+7 -1
View File
@@ -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'];
}