diff --git a/src/Authorization/Service/MailService.php b/src/Authorization/Service/MailService.php index 78684e214..8e838790b 100644 --- a/src/Authorization/Service/MailService.php +++ b/src/Authorization/Service/MailService.php @@ -33,6 +33,8 @@ */ final readonly class MailService implements MailServiceInterface { + private const RESET_MAIL_TEXT = "Login to pimcore and change your password using the following link. + This temporary login link will expire in 24 hours: \r\n\r\n %s"; private string $domain; public function __construct( @@ -76,16 +78,10 @@ public function sendResetPasswordMail(UserInterface $user, string $token): void try { $mail = $this->toolResolver->getMail([$user->getEmail()], 'Pimcore lost password service'); $mail->setIgnoreDebugMode(true); - $mail->text( - sprintf( - "Login to pimcore and change your password using the following link. - This temporary login link will expire in 24 hours: \r\n\r\n %s", - $loginUrl - ) - ); + $mail->text(sprintf(self::RESET_MAIL_TEXT, $loginUrl)); $mail->send(); - } catch (Exception $e) { - throw new SendMailException(); + } catch (Exception $exception) { + throw new SendMailException($exception->getMessage()); } } } diff --git a/src/Exception/SendMailException.php b/src/Exception/SendMailException.php index 336ebf7b9..a8c5a0282 100644 --- a/src/Exception/SendMailException.php +++ b/src/Exception/SendMailException.php @@ -16,16 +16,18 @@ namespace Pimcore\Bundle\StudioBackendBundle\Exception; +use Throwable; + /** * @internal */ final class SendMailException extends AbstractApiException { - public function __construct() + public function __construct(string $originalMessage) { parent::__construct( 500, - 'Failed to send reset password mail' + sprintf('Failed to send reset password mail: %s', $originalMessage), ); } }