diff --git a/src/Authentication/Actions/Email2FA.php b/src/Authentication/Actions/Email2FA.php index 2d9cf2bd3..4b38318a8 100644 --- a/src/Authentication/Actions/Email2FA.php +++ b/src/Authentication/Actions/Email2FA.php @@ -88,10 +88,15 @@ public function handle(IncomingRequest $request) // Send the user an email with the code helper('email'); - $email = emailer()->setFrom(setting('Email.fromEmail'), setting('Email.fromName') ?? ''); + $email = emailer(['mailType' => 'html']) + ->setFrom(setting('Email.fromEmail'), setting('Email.fromName') ?? ''); $email->setTo($user->email); $email->setSubject(lang('Auth.email2FASubject')); - $email->setMessage($this->view(setting('Auth.views')['action_email_2fa_email'], ['code' => $identity->secret, 'ipAddress' => $ipAddress, 'userAgent' => $userAgent, 'date' => $date])); + $email->setMessage($this->view( + setting('Auth.views')['action_email_2fa_email'], + ['code' => $identity->secret, 'ipAddress' => $ipAddress, 'userAgent' => $userAgent, 'date' => $date], + ['debug' => false] + )); if ($email->send(false) === false) { throw new RuntimeException('Cannot send email for user: ' . $user->email . "\n" . $email->printDebugger(['headers'])); diff --git a/src/Authentication/Actions/EmailActivator.php b/src/Authentication/Actions/EmailActivator.php index f91316cc3..2dd14d5e6 100644 --- a/src/Authentication/Actions/EmailActivator.php +++ b/src/Authentication/Actions/EmailActivator.php @@ -65,10 +65,15 @@ public function show(): string // Send the email helper('email'); - $email = emailer()->setFrom(setting('Email.fromEmail'), setting('Email.fromName') ?? ''); + $email = emailer(['mailType' => 'html']) + ->setFrom(setting('Email.fromEmail'), setting('Email.fromName') ?? ''); $email->setTo($userEmail); $email->setSubject(lang('Auth.emailActivateSubject')); - $email->setMessage($this->view(setting('Auth.views')['action_email_activate_email'], ['code' => $code, 'ipAddress' => $ipAddress, 'userAgent' => $userAgent, 'date' => $date])); + $email->setMessage($this->view( + setting('Auth.views')['action_email_activate_email'], + ['code' => $code, 'ipAddress' => $ipAddress, 'userAgent' => $userAgent, 'date' => $date], + ['debug' => false] + )); if ($email->send(false) === false) { throw new RuntimeException('Cannot send email for user: ' . $user->email . "\n" . $email->printDebugger(['headers'])); diff --git a/src/Controllers/MagicLinkController.php b/src/Controllers/MagicLinkController.php index 65034ec7e..4b0d48344 100644 --- a/src/Controllers/MagicLinkController.php +++ b/src/Controllers/MagicLinkController.php @@ -121,10 +121,15 @@ public function loginAction() // Send the user an email with the code helper('email'); - $email = emailer()->setFrom(setting('Email.fromEmail'), setting('Email.fromName') ?? ''); + $email = emailer(['mailType' => 'html']) + ->setFrom(setting('Email.fromEmail'), setting('Email.fromName') ?? ''); $email->setTo($user->email); $email->setSubject(lang('Auth.magicLinkSubject')); - $email->setMessage($this->view(setting('Auth.views')['magic-link-email'], ['token' => $token, 'ipAddress' => $ipAddress, 'userAgent' => $userAgent, 'date' => $date])); + $email->setMessage($this->view( + setting('Auth.views')['magic-link-email'], + ['token' => $token, 'ipAddress' => $ipAddress, 'userAgent' => $userAgent, 'date' => $date], + ['debug' => false] + )); if ($email->send(false) === false) { log_message('error', $email->printDebugger(['headers'])); diff --git a/src/Helpers/email_helper.php b/src/Helpers/email_helper.php index 20e9ccf47..35a28908b 100644 --- a/src/Helpers/email_helper.php +++ b/src/Helpers/email_helper.php @@ -17,6 +17,8 @@ /** * Provides convenient access to the CodeIgniter Email class. * + * @param array $overrides Email preferences to override. + * * @internal */ function emailer(array $overrides = []): Email @@ -46,7 +48,7 @@ function emailer(array $overrides = []): Email ]; if ($overrides !== []) { - $config = array_merge($overrides, $config); + $config = array_merge($config, $overrides); } /** @var Email $email */