* @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 SendActivationEmailService { public function __construct( private LoggerInterface $logger, private MailerInterface $mailer, ) { } public function send(User $user, string $activationUrl): void { try { $this->mailer->send( new TemplatedEmail() ->from('noreply@mineseeker.hu') ->to($user->email) ->subject('Activate your MineSeeker account') ->htmlTemplate('emails/activation.html.twig') ->context([ 'username' => $user->getUsername(), 'activation_url' => $activationUrl, ]) ); } catch (TransportExceptionInterface|Exception $e) { $this->logger->error("Failed to send activation email: {$e->getMessage()}", [ 'exception' => $e, 'user' => $user->getUsername(), ]); throw new RuntimeException("Failed to send activation email: {$e->getMessage()}"); } } }