* @category Class * @license https://www.gnu.org/licenses/lgpl-3.0.en.html GNU Lesser General Public License * @link www.splendidbear.org * @since 2026. 04. 20. */ readonly final class SendUserRegistrationNotificationService { public function __construct( #[Autowire(env: 'APP_CONTACT_MAIL_ADDRESS')] private string $appContactMailAddress, private LoggerInterface $logger, private MailerInterface $mailer, ) { } public function send(User $user, DateTime $registeredAt): void { try { $this->mailer->send( new TemplatedEmail() ->from('noreply@mineseeker.hu') ->to($this->appContactMailAddress) ->subject("🎉 New User Registration: {$user->getUsername()}") ->htmlTemplate('emails/user_registration_notification.html.twig') ->context([ 'user' => $user, 'registeredAt' => $registeredAt, ]) ); } catch (TransportExceptionInterface|Exception $e) { $this->logger->error("Failed to send user registration notification: {$e->getMessage()}", [ 'exception' => $e, 'user' => $user->getUsername(), ]); throw new RuntimeException("Failed to send user registration notification: {$e->getMessage()}"); } } }