Commit e44c7beb authored by Simon Gadient's avatar Simon Gadient

[IMP] Add a logger to the spool command

refs KIME-3340
parent 80eecf34
......@@ -40,6 +40,12 @@ class SwiftMailerSpoolCommandController extends CommandController {
*/
protected $configurationManager;
/**
* @Flow\Inject
* @var \WE\SwiftMailerSpool\Log\SwiftMailerSpoolLoggerInterface
*/
protected $logger;
/**
* Flush the email spool queue
*
......@@ -50,8 +56,13 @@ class SwiftMailerSpoolCommandController extends CommandController {
$realTransport = $this->transportFactory->create($settings['transport']['type'], $settings['transport']['options'], $settings['transport']['arguments']);
/** @var \Swift_Spool $spool */
$spool = $this->spoolMailer->getTransport()->getSpool();
$sent = $spool->flushQueue($realTransport);
$this->outputLine($sent . ' mails sent');
$failedRecipients = array();
$sent = $spool->flushQueue($realTransport, $failedRecipients);
$this->logger->log($sent . ' mails sent.');
$count = count($failedRecipients);
if ($count > 0) {
$this->logger->log($count . ' recipients failed. Check the spool to see the messages.', LOG_WARNING);
}
}
}
<?php
namespace WE\SwiftMailerSpool\Log;
/* *
* This script belongs to the Flow package "SwiftMailerSpool". *
* *
* It is free software; you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License, either version 3 *
* of the License, or (at your option) any later version. *
* *
* The TYPO3 project - inspiring people to share! *
* */
/**
* Logger interface for the SwiftMailerSpool package
*
* @author Simon Gadient <simon@web-essentials.asia>
*/
interface SwiftMailerSpoolLoggerInterface extends \TYPO3\Flow\Log\LoggerInterface {
}
......@@ -13,3 +13,16 @@ TYPO3\SwiftMailer\MailerInterface:
arguments:
1:
object: WE\SwiftMailerSpool\SpoolTransportInterface
WE\SwiftMailerSpool\Log\SwiftMailerSpoolLoggerInterface:
scope: singleton
factoryObjectName: TYPO3\Flow\Log\LoggerFactory
arguments:
1:
value: 'SystemLogger'
2:
setting: TYPO3.Flow.log.systemLogger.logger
3:
setting: TYPO3.Flow.log.systemLogger.backend
4:
setting: TYPO3.Flow.log.systemLogger.backendOptions
......@@ -15,8 +15,8 @@ The package is pre-configured to use a the file spool:
## Usage
Different from the [Neos Swift Mailer](https://github.com/neos/swiftmailer), a `\Swift_Message` has to be created instead
of using the `\TYPO3\SwiftMailer\Message` object. This is due to a problems on the serialization of the message that
happens in the `\FileSpool` as the serialized `\TYPO3\SwiftMailer\Message` does not include its parent properties of the
of using the `\TYPO3\SwiftMailer\Message` object. This is due to a problem on the serialization of the message that
happens in the `\FileSpool` as the serialized `\TYPO3\SwiftMailer\Message` does not include its private parent properties of the
`\Swift_Message`.
The process is the same as with the normal SwiftMailer library.
......
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