Commit 8a5834ad authored by Simon Gadient's avatar Simon Gadient

[FEATURE] Add message and time limit for spool

The limits can be set in the settings file. It prevents the application
reaching some limits set by the mail server.
parent e44c7beb
......@@ -52,10 +52,17 @@ class SwiftMailerSpoolCommandController extends CommandController {
* @throws \TYPO3\SwiftMailer\Exception
*/
public function flushCommand() {
$settings = $this->configurationManager->getConfiguration(\TYPO3\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'TYPO3.SwiftMailer');
$realTransport = $this->transportFactory->create($settings['transport']['type'], $settings['transport']['options'], $settings['transport']['arguments']);
/** @var \Swift_Spool $spool */
$swiftMailerSettings = $this->configurationManager->getConfiguration(\TYPO3\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'TYPO3.SwiftMailer');
$realTransport = $this->transportFactory->create($swiftMailerSettings['transport']['type'], $swiftMailerSettings['transport']['options'], $swiftMailerSettings['transport']['arguments']);
$swiftMailerSpoolSettings = $this->configurationManager->getConfiguration(\TYPO3\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'WE.SwiftMailerSpool');
/** @var \Swift_ConfigurableSpool $spool */
$spool = $this->spoolMailer->getTransport()->getSpool();
if (is_int($swiftMailerSpoolSettings['spool']['timeLimit'])) {
$spool->setTimeLimit($swiftMailerSpoolSettings['spool']['timeLimit']);
}
if (is_int($swiftMailerSpoolSettings['spool']['messageLimit'])) {
$spool->setMessageLimit($swiftMailerSpoolSettings['spool']['messageLimit']);
}
$failedRecipients = array();
$sent = $spool->flushQueue($realTransport, $failedRecipients);
$this->logger->log($sent . ' mails sent.');
......
......@@ -5,3 +5,5 @@ WE:
options: []
arguments:
path: %FLOW_PATH_DATA%/SwiftMailerSpool/
timeLimit: ~
messageLimit: ~
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment