From 23ff8d36199c0cddb5bae4a5010cb71f861eeef8 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Tue, 29 Dec 2015 09:59:46 +0100 Subject: Add custom email for 2FA Related #1490 --- src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php | 93 +++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php (limited to 'src/Wallabag/UserBundle/Mailer') diff --git a/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php b/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php new file mode 100644 index 00000000..f1960070 --- /dev/null +++ b/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php @@ -0,0 +1,93 @@ +mailer = $mailer; + $this->translator = $translator; + $this->senderEmail = $senderEmail; + $this->senderName = $senderName; + $this->supportUrl = $supportUrl; + } + + /** + * Send the auth code to the user via email. + * + * @param TwoFactorInterface $user + */ + public function sendAuthCode(TwoFactorInterface $user) + { + $message = new \Swift_Message(); + $message + ->setTo($user->getEmail()) + ->setFrom($this->senderEmail, $this->senderName) + ->setSubject($this->translator->trans('auth_code.mailer.subject', array(), 'wallabag_user')) + ->setBody($this->translator->trans( + 'auth_code.mailer.body', + [ + '%user%' => $user->getName(), + '%code%' => $user->getEmailAuthCode(), + '%support%' => $this->supportUrl, + ], + 'wallabag_user' + )) + ; + + $this->mailer->send($message); + } +} -- cgit v1.2.3