addArgument('to', InputArgument::REQUIRED, 'Recipient email address') ->addOption('subject', null, InputOption::VALUE_REQUIRED, 'Email subject', 'EscapePage mailer test') ->addOption('from', null, InputOption::VALUE_REQUIRED, 'Sender email address (defaults to MAILER_FROM if set)') ->addOption('from-name', null, InputOption::VALUE_REQUIRED, 'Sender name', 'EscapePage'); } protected function execute(InputInterface $input, OutputInterface $output): int { $to = (string) $input->getArgument('to'); $subject = (string) $input->getOption('subject'); $fromEmail = (string) ($input->getOption('from') ?? ($_ENV['MAILER_FROM'] ?? $_SERVER['MAILER_FROM'] ?? 'no-reply@example.com')); $fromName = (string) $input->getOption('from-name'); $email = (new Email()) ->from(new Address($fromEmail, $fromName)) ->to($to) ->subject($subject) ->html('

This is a test email sent at ' . date('c') . '.

If you see this, your mailer setup works.

') ->text('This is a test email sent at ' . date('c') . ". If you see this, your mailer setup works."); $this->mailer->send($email); $output->writeln('Test email sent to ' . $to . '.'); return Command::SUCCESS; } }