addOption('message-limit', null, InputOption::VALUE_REQUIRED, 'The maximum number of messages to send.') ->addOption('time-limit', null, InputOption::VALUE_REQUIRED, 'The time limit for sending messages (in seconds).') ->addOption('recover-timeout', null, InputOption::VALUE_REQUIRED, 'The timeout for recovering messages that have taken too long to send (in seconds).'); } /** * Executes the mailer command */ protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); $transport = $this->mailer->getTransport(); if ($transport instanceof DelayedTransportInterface) { if ($transport instanceof FileSpool) { $transport->setMessageLimit((int)$input->getOption('message-limit')); $transport->setTimeLimit((int)$input->getOption('time-limit')); $recoverTimeout = (int)$input->getOption('recover-timeout'); if ($recoverTimeout) { $transport->recover($recoverTimeout); } else { $transport->recover(); } } $sent = $transport->flushQueue($this->mailer->getRealTransport()); $io->comment($sent . ' emails sent'); return Command::SUCCESS; } $io->error('The Mailer Transport is not set to "spool".'); return Command::FAILURE; } }