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

[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
Loading
Loading
Loading
Loading
+10 −3
Original line number Original line Diff line number Diff line
@@ -52,10 +52,17 @@ class SwiftMailerSpoolCommandController extends CommandController {
	 * @throws \TYPO3\SwiftMailer\Exception
	 * @throws \TYPO3\SwiftMailer\Exception
	 */
	 */
	public function flushCommand() {
	public function flushCommand() {
		$settings = $this->configurationManager->getConfiguration(\TYPO3\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'TYPO3.SwiftMailer');
		$swiftMailerSettings = $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']);
		$realTransport = $this->transportFactory->create($swiftMailerSettings['transport']['type'], $swiftMailerSettings['transport']['options'], $swiftMailerSettings['transport']['arguments']);
		/** @var \Swift_Spool $spool */
		$swiftMailerSpoolSettings = $this->configurationManager->getConfiguration(\TYPO3\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'WE.SwiftMailerSpool');
		/** @var \Swift_ConfigurableSpool $spool */
		$spool = $this->spoolMailer->getTransport()->getSpool();
		$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();
		$failedRecipients = array();
		$sent = $spool->flushQueue($realTransport, $failedRecipients);
		$sent = $spool->flushQueue($realTransport, $failedRecipients);
		$this->logger->log($sent . ' mails sent.');
		$this->logger->log($sent . ' mails sent.');
+2 −0
Original line number Original line Diff line number Diff line
@@ -5,3 +5,5 @@ WE:
      options: []
      options: []
      arguments:
      arguments:
        path: %FLOW_PATH_DATA%/SwiftMailerSpool/
        path: %FLOW_PATH_DATA%/SwiftMailerSpool/
      timeLimit: ~
      messageLimit: ~