feat(email-templates): render email body using new templates

This commit is contained in:
Christy Jacob
2021-07-27 21:33:39 +05:30
parent 196fbeca8a
commit 3b573745bd
4 changed files with 62 additions and 28 deletions
+11 -2
View File
@@ -4,7 +4,7 @@
<head>
<meta name="viewport" content="width=device-width" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>{{title}}</title>
<title>{{subject}}</title>
<style>
body {
background-color: {{bg-body}};
@@ -136,7 +136,16 @@
<td class="wrapper">
<table role="presentation" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>{{content}}</td>
<td>
<p>{{hello}}</p>
<p>{{body}}</p>
<a href="{{redirect}}" target="_blank">{{redirect}}</a>
<p></br>{{footer}}</p>
<p>{{thanks}}
</br>
{{signature}}
</p>
</td>
</tr>
</table>
</td>
+23 -7
View File
@@ -2,13 +2,29 @@
"settings.inspire": "\"The art of being wise is the art of knowing what to overlook.\"",
"settings.locale": "en",
"settings.direction": "ltr",
"account.emails.team": "%s Team",
"account.emails.verification.title": "Account Verification",
"account.emails.verification.body": "\n Hello {{name}},\n\n\n Follow this link to verify your email address.\n\n{{cta}}\n\n If you didnt ask to verify this address, you can ignore this message.\n\n\n Thanks,\n {{project}} team\n",
"account.emails.recovery.title": "Password Reset",
"account.emails.recovery.body": "\n Hello {{name}},\n\n\n Follow this link to reset your {{project}} password.\n\n{{cta}}\n\n If you didnt ask to reset your password, you can ignore this message.\n\n\n Thanks,\n {{project}} team\n\n",
"account.emails.invitation.title": "Invitation to %s Team at %s",
"account.emails.invitation.body": "\n Hello,\n\n\n This mail was sent to you because {{owner}} wanted to invite you to become a member of the {{team}} team at {{project}}.\n\n{{cta}}\n\n If you are not interested, you can ignore this message.\n\n Thanks,\n {{project}} team\n\n",
"emails.sender": "%s Team",
"emails.verification.subject": "Account Verification",
"emails.verification.hello": "Hey {{name}}",
"emails.verification.body": "Follow this link to verify your email address.",
"emails.verification.footer": "If you didnt ask to verify this address, you can ignore this message.",
"emails.verification.thanks": "Thanks",
"emails.verification.signature": "{{project}} team",
"emails.recovery.subject": "Password Reset",
"emails.recovery.hello": "Hello {{name}}",
"emails.recovery.body": "Follow this link to reset your {{project}} password.",
"emails.recovery.footer": "If you didnt ask to reset your password, you can ignore this message.",
"emails.recovery.thanks": "Thanks",
"emails.recovery.signature": "{{project}} team",
"emails.invitation.subject": "Invitation to %s Team at %s",
"emails.invitation.hello": "Hello",
"emails.invitation.body": "This mail was sent to you because {{owner}} wanted to invite you to become a member of the {{team}} team at {{project}}.",
"emails.invitation.footer": "If you are not interested, you can ignore this message.",
"emails.invitation.thanks": "Thanks",
"emails.invitation.signature": "{{project}} team",
"locale.country.unknown": "Unknown",
"countries.af": "Afghanistan",
"countries.ao": "Angola",
+18 -12
View File
@@ -1516,15 +1516,18 @@ App::post('/v1/account/recovery')
$url = Template::unParseURL($url);
$body = Template::fromFile(__DIR__.'/../../config/locale/templates/email-base.tpl');
$content = Template::fromString($locale->getText('account.emails.recovery.body'));
$body
->setParam('{{content}}', $content->render(false))
->setParam('{{title}}', $locale->getText('account.emails.recovery.title'))
->setParam('{{subject}}', $locale->getText('emails.recovery.subject'))
->setParam('{{hello}}', $locale->getText('emails.recovery.hello'))
->setParam('{{body}}', $locale->getText('emails.recovery.body'))
->setParam('{{redirect}}', $url)
->setParam('{{footer}}', $locale->getText('emails.recovery.footer'))
->setParam('{{thanks}}', $locale->getText('emails.recovery.thanks'))
->setParam('{{signature}}', $locale->getText('emails.recovery.signature'))
->setParam('{{direction}}', $locale->getText('settings.direction'))
->setParam('{{project}}', $project->getAttribute('name', ['[APP-NAME]']))
->setParam('{{name}}', $profile->getAttribute('name'))
->setParam('{{redirect}}', $url)
->setParam('{{bg-body}}', '#f7f7f7')
->setParam('{{bg-content}}', '#ffffff')
->setParam('{{text-content}}', '#000000')
@@ -1532,10 +1535,10 @@ App::post('/v1/account/recovery')
$mails
->setParam('event', 'account.recovery.create')
->setParam('from', ($project->getId() === 'console') ? '' : \sprintf($locale->getText('account.emails.team'), $project->getAttribute('name')))
->setParam('from', ($project->getId() === 'console') ? '' : \sprintf($locale->getText('emails.sender'), $project->getAttribute('name')))
->setParam('recipient', $profile->getAttribute('email', ''))
->setParam('name', $profile->getAttribute('name', ''))
->setParam('subject', $locale->getText('account.emails.recovery.title'))
->setParam('subject', $locale->getText('emails.recovery.subject'))
->setParam('body', $body->render())
->trigger();
;
@@ -1716,15 +1719,18 @@ App::post('/v1/account/verification')
$url = Template::unParseURL($url);
$body = Template::fromFile(__DIR__.'/../../config/locale/templates/email-base.tpl');
$content = Template::fromString($locale->getText('account.emails.verification.body'));
$body
->setParam('{{content}}', $content->render(false))
->setParam('{{title}}', $locale->getText('account.emails.verification.title'))
->setParam('{{subject}}', $locale->getText('emails.verification.subject'))
->setParam('{{hello}}', $locale->getText('emails.verification.hello'))
->setParam('{{body}}', $locale->getText('emails.verification.body'))
->setParam('{{redirect}}', $url)
->setParam('{{footer}}', $locale->getText('emails.verification.footer'))
->setParam('{{thanks}}', $locale->getText('emails.verification.thanks'))
->setParam('{{signature}}', $locale->getText('emails.verification.signature'))
->setParam('{{direction}}', $locale->getText('settings.direction'))
->setParam('{{project}}', $project->getAttribute('name', ['[APP-NAME]']))
->setParam('{{name}}', $user->getAttribute('name'))
->setParam('{{redirect}}', $url)
->setParam('{{bg-body}}', '#f7f7f7')
->setParam('{{bg-content}}', '#ffffff')
->setParam('{{text-content}}', '#000000')
@@ -1732,10 +1738,10 @@ App::post('/v1/account/verification')
$mails
->setParam('event', 'account.verification.create')
->setParam('from', ($project->getId() === 'console') ? '' : \sprintf($locale->getText('account.emails.team'), $project->getAttribute('name')))
->setParam('from', ($project->getId() === 'console') ? '' : \sprintf($locale->getText('emails.sender'), $project->getAttribute('name')))
->setParam('recipient', $user->getAttribute('email'))
->setParam('name', $user->getAttribute('name'))
->setParam('subject', $locale->getText('account.emails.verification.title'))
->setParam('subject', $locale->getText('emails.verification.subject'))
->setParam('body', $body->render())
->trigger()
;
+10 -7
View File
@@ -420,17 +420,20 @@ App::post('/v1/teams/:teamId/memberships')
$url = Template::unParseURL($url);
$body = Template::fromFile(__DIR__.'/../../config/locale/templates/email-base.tpl');
$content = Template::fromString($locale->getText('account.emails.invitation.body'));
$title = \sprintf($locale->getText('account.emails.invitation.title'), $team->getAttribute('name', '[TEAM-NAME]'), $project->getAttribute('name', ['[APP-NAME]']));
$subject = \sprintf($locale->getText('emails.invitation.subject'), $team->getAttribute('name', '[TEAM-NAME]'), $project->getAttribute('name', ['[APP-NAME]']));
$body
->setParam('{{content}}', $content->render(false))
->setParam('{{title}}', $title)
->setParam('{{subject}}', $subject)
->setParam('{{hello}}', $locale->getText('emails.invitation.hello'))
->setParam('{{body}}', $locale->getText('emails.invitation.body'))
->setParam('{{redirect}}', $url)
->setParam('{{footer}}', $locale->getText('emails.invitation.footer'))
->setParam('{{thanks}}', $locale->getText('emails.invitation.thanks'))
->setParam('{{signature}}', $locale->getText('emails.invitation.signature'))
->setParam('{{direction}}', $locale->getText('settings.direction'))
->setParam('{{project}}', $project->getAttribute('name', ['[APP-NAME]']))
->setParam('{{team}}', $team->getAttribute('name', '[TEAM-NAME]'))
->setParam('{{owner}}', $user->getAttribute('name', ''))
->setParam('{{redirect}}', $url)
->setParam('{{bg-body}}', '#f7f7f7')
->setParam('{{bg-content}}', '#ffffff')
->setParam('{{text-content}}', '#000000')
@@ -439,10 +442,10 @@ App::post('/v1/teams/:teamId/memberships')
if (!$isPrivilegedUser && !$isAppUser) { // No need of confirmation when in admin or app mode
$mails
->setParam('event', 'teams.memberships.create')
->setParam('from', ($project->getId() === 'console') ? '' : \sprintf($locale->getText('account.emails.team'), $project->getAttribute('name')))
->setParam('from', ($project->getId() === 'console') ? '' : \sprintf($locale->getText('emails.sender'), $project->getAttribute('name')))
->setParam('recipient', $email)
->setParam('name', $name)
->setParam('subject', $title)
->setParam('subject', $subject)
->setParam('body', $body->render())
->trigger()
;