merged branch timewasted/patch-1 (PR #3158)
Commits -------9e55cda
Only call recover() when spool is a Swift_FileSpoold2a0c74
Use if/else instead of ternary operator15c666b
Add a "recover-timeout" option to allow recovering messages that have taken too long to send Discussion ---------- [SwiftmailerBundle] Add a "recover-timeout" option to swiftmailer:spool:send This would allow for easy resending of messages that were marked as being sent, but for whatever reason were never actually sent.
This commit is contained in:
commit
09694999b8
@ -34,10 +34,11 @@ class SendEmailCommand extends ContainerAwareCommand
|
|||||||
->setDescription('Sends emails from the spool')
|
->setDescription('Sends emails from the spool')
|
||||||
->addOption('message-limit', 0, InputOption::VALUE_OPTIONAL, 'The maximum number of messages to send.')
|
->addOption('message-limit', 0, InputOption::VALUE_OPTIONAL, 'The maximum number of messages to send.')
|
||||||
->addOption('time-limit', 0, InputOption::VALUE_OPTIONAL, 'The time limit for sending messages (in seconds).')
|
->addOption('time-limit', 0, InputOption::VALUE_OPTIONAL, 'The time limit for sending messages (in seconds).')
|
||||||
|
->addOption('recover-timeout', 0, InputOption::VALUE_OPTIONAL, 'The timeout for recovering messages that have taken too long to send (in seconds).')
|
||||||
->setHelp(<<<EOF
|
->setHelp(<<<EOF
|
||||||
The <info>swiftmailer:spool:send</info> command sends all emails from the spool.
|
The <info>swiftmailer:spool:send</info> command sends all emails from the spool.
|
||||||
|
|
||||||
<info>php app/console swiftmailer:spool:send --message-limit=10 --time-limit=10</info>
|
<info>php app/console swiftmailer:spool:send --message-limit=10 --time-limit=10 --recover-timeout=900</info>
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
@ -58,6 +59,13 @@ EOF
|
|||||||
$spool->setMessageLimit($input->getOption('message-limit'));
|
$spool->setMessageLimit($input->getOption('message-limit'));
|
||||||
$spool->setTimeLimit($input->getOption('time-limit'));
|
$spool->setTimeLimit($input->getOption('time-limit'));
|
||||||
}
|
}
|
||||||
|
if ($spool instanceof \Swift_FileSpool) {
|
||||||
|
if (null !== $input->getOption('recover-timeout')) {
|
||||||
|
$spool->recover($input->getOption('recover-timeout'));
|
||||||
|
} else {
|
||||||
|
$spool->recover();
|
||||||
|
}
|
||||||
|
}
|
||||||
$sent = $spool->flushQueue($this->getContainer()->get('swiftmailer.transport.real'));
|
$sent = $spool->flushQueue($this->getContainer()->get('swiftmailer.transport.real'));
|
||||||
|
|
||||||
$output->writeln(sprintf('sent %s emails', $sent));
|
$output->writeln(sprintf('sent %s emails', $sent));
|
||||||
|
Reference in New Issue
Block a user