diff options
author | Igor Scheller <igor.scheller@igorshp.de> | 2018-09-26 21:28:49 +0200 |
---|---|---|
committer | Igor Scheller <igor.scheller@igorshp.de> | 2018-09-26 21:31:18 +0200 |
commit | 6187eed3bb08f200050a3078bd762b5731dfbe78 (patch) | |
tree | 06e0b08294c66449ed5f9f046a3bfe2097c7b4ad /src/Mail/Transport/LogTransport.php | |
parent | bc5764b33ffc8a92dfa1d788ba2a204dd991c3d9 (diff) | |
parent | d36de2d26f5af76d5d4f34f8620694c6d0368983 (diff) |
Merge remote-tracking branch 'MyIgel/mailing'
Diffstat (limited to 'src/Mail/Transport/LogTransport.php')
-rw-r--r-- | src/Mail/Transport/LogTransport.php | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/Mail/Transport/LogTransport.php b/src/Mail/Transport/LogTransport.php new file mode 100644 index 00000000..6e351302 --- /dev/null +++ b/src/Mail/Transport/LogTransport.php @@ -0,0 +1,44 @@ +<?php + +namespace Engelsystem\Mail\Transport; + +use Psr\Log\LoggerInterface; +use Swift_Mime_SimpleMessage as SimpleMessage; + +class LogTransport extends Transport +{ + /** @var LoggerInterface */ + protected $logger; + + public function __construct(LoggerInterface $logger) + { + $this->logger = $logger; + } + + /** + * Send the given Message. + * + * Recipient/sender data will be retrieved from the Message API. + * The return value is the number of recipients + * + * @param SimpleMessage $message + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int + */ + public function send( + SimpleMessage $message, + &$failedRecipients = null + ): int { + $this->logger->debug( + 'Mail: Send mail "{title}" to "{recipients}":' . PHP_EOL . '{content}', + [ + 'title' => $message->getSubject(), + 'recipients' => $this->getTo($message), + 'content' => (string)$message->getHeaders() . PHP_EOL . PHP_EOL . $message->toString(), + ] + ); + + return count($this->allRecipients($message)); + } +} |