addArgument('to', InputArgument::REQUIRED, 'The email address to send the email to'); $this->addOption('from', null, InputOption::VALUE_OPTIONAL, 'Deprecated: uses the MAILER_FROM env variable.'); } protected function execute(InputInterface $input, OutputInterface $output): int { $to = $input->getArgument('to'); if (!\is_string($to) || $to === '') { throw new \InvalidArgumentException('Need a non-empty "to" address'); } if ($input->getOption('from') !== null) { throw new \InvalidArgumentException('The "from" option is deprecated and will be ignored'); } $message = new Email(); $message->to($to); $message->subject('Test email - ' . Constants::SOFTWARE); $message->text('This is a test email from your time-tracker'); $this->dispatcher->dispatch(new EmailEvent($message)); return Command::SUCCESS; } }