diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index dfa8cb0b7a..aae105f0b8 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -544,7 +544,7 @@ App::post('/v1/teams/:teamId/memberships') $projectName = $project->isEmpty() ? 'Console' : $project->getAttribute('name', '[APP-NAME]'); $from = $project->isEmpty() || $project->getId() === 'console' ? '' : \sprintf($locale->getText('emails.sender'), $projectName); - $body = Template::fromFile(__DIR__ . '/../../config/locale/templates/email-base.tpl'); + $body = $locale->getText("emails.invitation.body"); $subject = \sprintf($locale->getText("emails.invitation.subject"), $team->getAttribute('name'), $projectName); $smtpEnabled = $project->getAttribute('smtp', [])['enabled'] ?? false; @@ -566,25 +566,23 @@ App::post('/v1/teams/:teamId/memberships') ->setSmtpSenderName($customTemplate['senderName'] ?? ''); } - $body->setParam('{{owner}}', $user->getAttribute('name')); - $body->setParam('{{team}}', $team->getAttribute('name')); - - $body - ->setParam('{{subject}}', $subject) - ->setParam('{{hello}}', $locale->getText("emails.invitation.hello")) - ->setParam('{{name}}', $user->getAttribute('name')) - ->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('{{project}}', $projectName) - ->setParam('{{direction}}', $locale->getText('settings.direction')) - ->setParam('{{bg-body}}', '#f7f7f7') - ->setParam('{{bg-content}}', '#ffffff') - ->setParam('{{text-content}}', '#000000'); - - $body = $body->render(); + $emailVariables = [ + 'owner' => $user->getAttribute('name'), + 'team' => $team->getAttribute('name'), + 'subject' => $subject, + 'hello' => $locale->getText("emails.invitation.hello"), + 'name' => $user->getAttribute('name'), + 'body' => $body, + 'redirect' => $url, + 'footer' => $locale->getText("emails.invitation.footer"), + 'thanks' => $locale->getText("emails.invitation.thanks"), + 'signature' => $locale->getText("emails.invitation.signature"), + 'project' => $projectName, + 'direction' => $locale->getText('settings.direction'), + 'bg-body' => '#f7f7f7', + 'bg-content' => '#ffffff', + 'text-content' => '#000000', + ]; $mails ->setSubject($subject) @@ -592,6 +590,7 @@ App::post('/v1/teams/:teamId/memberships') ->setFrom($from) ->setRecipient($invitee->getAttribute('email')) ->setName($invitee->getAttribute('name')) + ->setVariables($emailVariables) ->trigger() ; } elseif (!empty($phone)) {