setName('mautic:email:fetch')
->setAliases(
[
'mautic:emails:fetch',
]
)
->addOption('--message-limit', '-m', InputOption::VALUE_OPTIONAL, 'Limit number of messages to process at a time.')
->setHelp(
<<<'EOT'
The %command.name% command is used to fetch and process messages such as bounces and unsubscribe requests. Configure the Monitored Email settings in Mautic's Configuration.
php %command.full_name%
EOT
);
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$limit = $input->getOption('message-limit');
$mailboxes = $this->parametersHelper->get('monitored_email');
unset($mailboxes['general']);
$mailboxes = array_keys($mailboxes);
$this->fetcher->setMailboxes($mailboxes)
->fetch($limit);
foreach ($this->fetcher->getLog() as $log) {
$output->writeln($log);
}
return Command::SUCCESS;
}
protected static $defaultDescription = 'Fetch and process monitored email.';
}