mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Support reply to name
This commit is contained in:
@@ -131,7 +131,8 @@ class Mails extends Listener
|
||||
->setSmtpUsername($smtp['username'] ?? '')
|
||||
->setSmtpPassword($smtp['password'] ?? '')
|
||||
->setSmtpSecure($smtp['secure'] ?? '')
|
||||
->setSmtpReplyTo($customTemplate['replyTo'] ?? $smtp['replyTo'] ?? '')
|
||||
->setSmtpReplyToEmail($customTemplate['replyToEmail'] ?? $smtp['replyToEmail'] ?? '')
|
||||
->setSmtpReplyToName($customTemplate['replyToName'] ?? $smtp['replyToName'] ?? '')
|
||||
->setSmtpSenderEmail($customTemplate['senderEmail'] ?? $smtp['senderEmail'] ?? System::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM))
|
||||
->setSmtpSenderName($customTemplate['senderName'] ?? $smtp['senderName'] ?? System::getEnv('_APP_SYSTEM_EMAIL_NAME', APP_NAME . ' Server'));
|
||||
}
|
||||
|
||||
@@ -251,14 +251,26 @@ class Mail extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* Set SMTP reply to
|
||||
* Set SMTP reply-to email
|
||||
*
|
||||
* @param string $replyTo
|
||||
* @param string $email
|
||||
* @return self
|
||||
*/
|
||||
public function setSmtpReplyTo(string $replyTo): self
|
||||
public function setSmtpReplyToEmail(string $email): self
|
||||
{
|
||||
$this->smtp['replyTo'] = $replyTo;
|
||||
$this->smtp['replyToEmail'] = $email;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set SMTP reply-to name
|
||||
*
|
||||
* @param string $name
|
||||
* @return self
|
||||
*/
|
||||
public function setSmtpReplyToName(string $name): self
|
||||
{
|
||||
$this->smtp['replyToName'] = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -333,13 +345,23 @@ class Mail extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* Get SMTP reply to
|
||||
* Get SMTP reply-to email
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSmtpReplyTo(): string
|
||||
public function getSmtpReplyToEmail(): string
|
||||
{
|
||||
return $this->smtp['replyTo'] ?? '';
|
||||
return $this->smtp['replyToEmail'] ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get SMTP reply-to name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSmtpReplyToName(): string
|
||||
{
|
||||
return $this->smtp['replyToName'] ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -253,7 +253,8 @@ class Create extends Action
|
||||
|
||||
$senderEmail = System::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM);
|
||||
$senderName = System::getEnv('_APP_SYSTEM_EMAIL_NAME', APP_NAME . ' Server');
|
||||
$replyTo = "";
|
||||
$replyToEmail = '';
|
||||
$replyToName = '';
|
||||
|
||||
if ($smtpEnabled) {
|
||||
if (!empty($smtp['senderEmail'])) {
|
||||
@@ -262,8 +263,11 @@ class Create extends Action
|
||||
if (!empty($smtp['senderName'])) {
|
||||
$senderName = $smtp['senderName'];
|
||||
}
|
||||
if (!empty($smtp['replyTo'])) {
|
||||
$replyTo = $smtp['replyTo'];
|
||||
if (!empty($smtp['replyToEmail'])) {
|
||||
$replyToEmail = $smtp['replyToEmail'];
|
||||
}
|
||||
if (!empty($smtp['replyToName'])) {
|
||||
$replyToName = $smtp['replyToName'];
|
||||
}
|
||||
|
||||
$queueForMails
|
||||
@@ -280,8 +284,11 @@ class Create extends Action
|
||||
if (!empty($customTemplate['senderName'])) {
|
||||
$senderName = $customTemplate['senderName'];
|
||||
}
|
||||
if (!empty($customTemplate['replyTo'])) {
|
||||
$replyTo = $customTemplate['replyTo'];
|
||||
if (!empty($customTemplate['replyToEmail'])) {
|
||||
$replyToEmail = $customTemplate['replyToEmail'];
|
||||
}
|
||||
if (!empty($customTemplate['replyToName'])) {
|
||||
$replyToName = $customTemplate['replyToName'];
|
||||
}
|
||||
|
||||
$body = $customTemplate['message'] ?? '';
|
||||
@@ -289,7 +296,8 @@ class Create extends Action
|
||||
}
|
||||
|
||||
$queueForMails
|
||||
->setSmtpReplyTo($replyTo)
|
||||
->setSmtpReplyToEmail($replyToEmail)
|
||||
->setSmtpReplyToName($replyToName)
|
||||
->setSmtpSenderEmail($senderEmail)
|
||||
->setSmtpSenderName($senderName);
|
||||
}
|
||||
|
||||
@@ -104,7 +104,8 @@ class Create extends Action
|
||||
|
||||
$senderName = $paramSenderName ?: ($smtp['senderName'] ?? '');
|
||||
$senderEmail = $paramSenderEmail ?: ($smtp['senderEmail'] ?? '');
|
||||
$replyTo = $paramReplyTo ?: ($smtp['replyTo'] ?? '');
|
||||
$replyToEmail = $paramReplyTo ?: ($smtp['replyToEmail'] ?? '');
|
||||
$replyToName = $smtp['replyToName'] ?? '';
|
||||
$host = $paramHost ?: ($smtp['host'] ?? '');
|
||||
$port = $paramPort ?? ($smtp['port'] ?? '');
|
||||
$username = $paramUsername ?: ($smtp['username'] ?? '');
|
||||
@@ -127,13 +128,15 @@ class Create extends Action
|
||||
throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'SMTP port must be configured on the project to send a test email.');
|
||||
}
|
||||
|
||||
$replyToEmail = !empty($replyTo) ? $replyTo : $senderEmail;
|
||||
// Fallback to sender details when reply-to is not explicitly configured
|
||||
$replyToEmailDisplay = !empty($replyToEmail) ? $replyToEmail : $senderEmail;
|
||||
$replyToNameDisplay = !empty($replyToName) ? $replyToName : $senderName;
|
||||
|
||||
$subject = 'Custom SMTP email sample';
|
||||
$template = Template::fromFile(APP_CE_CONFIG_DIR . '/locale/templates/email-smtp-test.tpl');
|
||||
$template
|
||||
->setParam('{{from}}', "{$senderName} ({$senderEmail})")
|
||||
->setParam('{{replyTo}}', "{$senderName} ({$replyToEmail})")
|
||||
->setParam('{{replyTo}}', "{$replyToNameDisplay} ({$replyToEmailDisplay})")
|
||||
->setParam('{{logoUrl}}', $plan['logoUrl'] ?? APP_EMAIL_LOGO_URL)
|
||||
->setParam('{{accentColor}}', $plan['accentColor'] ?? APP_EMAIL_ACCENT_COLOR)
|
||||
->setParam('{{twitterUrl}}', $plan['twitterUrl'] ?? APP_SOCIAL_TWITTER)
|
||||
@@ -149,7 +152,8 @@ class Create extends Action
|
||||
->setSmtpUsername($username)
|
||||
->setSmtpPassword($password)
|
||||
->setSmtpSecure($secure)
|
||||
->setSmtpReplyTo($replyTo)
|
||||
->setSmtpReplyToEmail($replyToEmail)
|
||||
->setSmtpReplyToName($replyToName)
|
||||
->setSmtpSenderEmail($senderEmail)
|
||||
->setSmtpSenderName($senderName)
|
||||
->setRecipient($email)
|
||||
|
||||
@@ -341,7 +341,8 @@ class Create extends Action
|
||||
|
||||
$senderEmail = System::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM);
|
||||
$senderName = System::getEnv('_APP_SYSTEM_EMAIL_NAME', APP_NAME . ' Server');
|
||||
$replyTo = '';
|
||||
$replyToEmail = '';
|
||||
$replyToName = '';
|
||||
|
||||
if ($smtpEnabled) {
|
||||
if (! empty($smtp['senderEmail'])) {
|
||||
@@ -350,8 +351,11 @@ class Create extends Action
|
||||
if (! empty($smtp['senderName'])) {
|
||||
$senderName = $smtp['senderName'];
|
||||
}
|
||||
if (! empty($smtp['replyTo'])) {
|
||||
$replyTo = $smtp['replyTo'];
|
||||
if (! empty($smtp['replyToEmail'])) {
|
||||
$replyToEmail = $smtp['replyToEmail'];
|
||||
}
|
||||
if (! empty($smtp['replyToName'])) {
|
||||
$replyToName = $smtp['replyToName'];
|
||||
}
|
||||
|
||||
$queueForMails
|
||||
@@ -368,8 +372,11 @@ class Create extends Action
|
||||
if (! empty($customTemplate['senderName'])) {
|
||||
$senderName = $customTemplate['senderName'];
|
||||
}
|
||||
if (! empty($customTemplate['replyTo'])) {
|
||||
$replyTo = $customTemplate['replyTo'];
|
||||
if (! empty($customTemplate['replyToEmail'])) {
|
||||
$replyToEmail = $customTemplate['replyToEmail'];
|
||||
}
|
||||
if (! empty($customTemplate['replyToName'])) {
|
||||
$replyToName = $customTemplate['replyToName'];
|
||||
}
|
||||
|
||||
$body = $customTemplate['message'] ?? '';
|
||||
@@ -377,7 +384,8 @@ class Create extends Action
|
||||
}
|
||||
|
||||
$queueForMails
|
||||
->setSmtpReplyTo($replyTo)
|
||||
->setSmtpReplyToEmail($replyToEmail)
|
||||
->setSmtpReplyToName($replyToName)
|
||||
->setSmtpSenderEmail($senderEmail)
|
||||
->setSmtpSenderName($senderName);
|
||||
}
|
||||
|
||||
@@ -173,8 +173,8 @@ class Mails extends Action
|
||||
$replyTo = $customMailOptions['replyToEmail'] ?? $replyTo;
|
||||
$replyToName = $customMailOptions['replyToName'] ?? $replyToName;
|
||||
} elseif (!empty($smtp)) {
|
||||
$replyTo = !empty($smtp['replyTo']) ? $smtp['replyTo'] : ($smtp['senderEmail'] ?? $replyTo);
|
||||
$replyToName = $smtp['senderName'] ?? $replyToName;
|
||||
$replyTo = !empty($smtp['replyToEmail']) ? $smtp['replyToEmail'] : ($smtp['senderEmail'] ?? $replyTo);
|
||||
$replyToName = !empty($smtp['replyToName']) ? $smtp['replyToName'] : ($smtp['senderName'] ?? $replyToName);
|
||||
}
|
||||
|
||||
$attachments = null;
|
||||
|
||||
@@ -22,12 +22,18 @@ class TemplateEmail extends Template
|
||||
'default' => '',
|
||||
'example' => 'mail@appwrite.io',
|
||||
])
|
||||
->addRule('replyTo', [
|
||||
->addRule('replyToEmail', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Reply to email address',
|
||||
'default' => '',
|
||||
'example' => 'emails@appwrite.io',
|
||||
])
|
||||
->addRule('replyToName', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Reply to name',
|
||||
'default' => '',
|
||||
'example' => 'Support Team',
|
||||
])
|
||||
->addRule('subject', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Email subject',
|
||||
|
||||
Reference in New Issue
Block a user