4
* This file is part of SwiftMailer.
5
* (c) 2004-2009 Chris Corbyn
7
* For the full copyright and license information, please view the LICENSE
8
* file that was distributed with this source code.
11
//@require 'Swift/Events/SendListener.php';
12
//@require 'Swift/Events/SendEvent.php';
13
//@require 'Swift/Plugins/Reporter.php';
16
* Does real time reporting of pass/fail for each recipient.
19
* @author Chris Corbyn
21
class Swift_Plugins_ReporterPlugin
22
implements Swift_Events_SendListener
26
* The reporter backend which takes notifications.
27
* @var Swift_Plugin_Reporter
33
* Create a new ReporterPlugin using $reporter.
34
* @param Swift_Plugins_Reporter $reporter
36
public function __construct(Swift_Plugins_Reporter $reporter)
38
$this->_reporter = $reporter;
44
public function beforeSendPerformed(Swift_Events_SendEvent $evt)
49
* Invoked immediately after the Message is sent.
50
* @param Swift_Events_SendEvent $evt
52
public function sendPerformed(Swift_Events_SendEvent $evt)
54
$message = $evt->getMessage();
55
$failures = array_flip($evt->getFailedRecipients());
56
foreach ((array) $message->getTo() as $address => $null)
58
$this->_reporter->notify(
59
$message, $address, (array_key_exists($address, $failures)
60
? Swift_Plugins_Reporter::RESULT_FAIL
61
: Swift_Plugins_Reporter::RESULT_PASS)
64
foreach ((array) $message->getCc() as $address => $null)
66
$this->_reporter->notify(
67
$message, $address, (array_key_exists($address, $failures)
68
? Swift_Plugins_Reporter::RESULT_FAIL
69
: Swift_Plugins_Reporter::RESULT_PASS)
72
foreach ((array) $message->getBcc() as $address => $null)
74
$this->_reporter->notify(
75
$message, $address, (array_key_exists($address, $failures)
76
? Swift_Plugins_Reporter::RESULT_FAIL
77
: Swift_Plugins_Reporter::RESULT_PASS)