mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Fix missing platform variables in SMTP test email template
The SMTP test email uses email-base-styled.tpl as its base template,
which contains {{platform}}, {{logoUrl}}, {{accentColor}}, and social/
legal link placeholders. These were never passed as template variables,
causing them to render as literal strings (e.g. "{{platform}} logo").
Inject the platform config and pass the variables to MailMessage,
matching the pattern used by OTP and magic-url email flows.
Co-Authored-By: Harsh Mahajan <harsh@appwrite.io>
This commit is contained in:
@@ -69,6 +69,7 @@ class Create extends Action
|
||||
->inject('response')
|
||||
->inject('project')
|
||||
->inject('publisherForMails')
|
||||
->inject('platform')
|
||||
->inject('plan')
|
||||
->callback($this->action(...));
|
||||
}
|
||||
@@ -89,6 +90,7 @@ class Create extends Action
|
||||
Response $response,
|
||||
Document $project,
|
||||
MailPublisher $publisherForMails,
|
||||
array $platform,
|
||||
array $plan
|
||||
): void {
|
||||
// Backwards compatibility: use inline params if provided, otherwise fall back to project SMTP config.
|
||||
@@ -144,14 +146,7 @@ class Create extends Action
|
||||
$template = Template::fromFile(APP_CE_CONFIG_DIR . '/locale/templates/email-smtp-test.tpl');
|
||||
$template
|
||||
->setParam('{{from}}', "{$senderName} ({$senderEmail})")
|
||||
->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)
|
||||
->setParam('{{discordUrl}}', $plan['discordUrl'] ?? APP_SOCIAL_DISCORD)
|
||||
->setParam('{{githubUrl}}', $plan['githubUrl'] ?? APP_SOCIAL_GITHUB_APPWRITE)
|
||||
->setParam('{{termsUrl}}', $plan['termsUrl'] ?? APP_EMAIL_TERMS_URL)
|
||||
->setParam('{{privacyUrl}}', $plan['privacyUrl'] ?? APP_EMAIL_PRIVACY_URL);
|
||||
->setParam('{{replyTo}}', "{$replyToNameDisplay} ({$replyToEmailDisplay})");
|
||||
|
||||
foreach ($emails as $email) {
|
||||
$publisherForMails->enqueue(new MailMessage(
|
||||
@@ -171,6 +166,17 @@ class Create extends Action
|
||||
'senderEmail' => $senderEmail,
|
||||
'senderName' => $senderName,
|
||||
],
|
||||
variables: [
|
||||
'platform' => $platform['platformName'] ?? APP_NAME,
|
||||
'logoUrl' => $platform['logoUrl'] ?? APP_EMAIL_LOGO_URL,
|
||||
'accentColor' => $platform['accentColor'] ?? APP_EMAIL_ACCENT_COLOR,
|
||||
'twitter' => $platform['twitterUrl'] ?? APP_SOCIAL_TWITTER,
|
||||
'discord' => $platform['discordUrl'] ?? APP_SOCIAL_DISCORD,
|
||||
'github' => $platform['githubUrl'] ?? APP_SOCIAL_GITHUB_APPWRITE,
|
||||
'terms' => $platform['termsUrl'] ?? APP_EMAIL_TERMS_URL,
|
||||
'privacy' => $platform['privacyUrl'] ?? APP_EMAIL_PRIVACY_URL,
|
||||
],
|
||||
platform: $platform,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user