1: <?php
2:
3: 4: 5: 6: 7: 8: 9:
10:
11: 12: 13: 14: 15: 16:
17: class Swift_Plugins_ReporterPlugin implements Swift_Events_SendListener
18: {
19: 20: 21: 22: 23:
24: private $_reporter;
25:
26: 27: 28: 29:
30: public function __construct(Swift_Plugins_Reporter $reporter)
31: {
32: $this->_reporter = $reporter;
33: }
34:
35: 36: 37:
38: public function beforeSendPerformed(Swift_Events_SendEvent $evt)
39: {
40: }
41:
42: 43: 44: 45:
46: public function sendPerformed(Swift_Events_SendEvent $evt)
47: {
48: $message = $evt->getMessage();
49: $failures = array_flip($evt->getFailedRecipients());
50: foreach ((array) $message->getTo() as $address => $null) {
51: $this->_reporter->notify(
52: $message, $address, (array_key_exists($address, $failures)
53: ? Swift_Plugins_Reporter::RESULT_FAIL
54: : Swift_Plugins_Reporter::RESULT_PASS)
55: );
56: }
57: foreach ((array) $message->getCc() 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)
62: );
63: }
64: foreach ((array) $message->getBcc() as $address => $null) {
65: $this->_reporter->notify(
66: $message, $address, (array_key_exists($address, $failures)
67: ? Swift_Plugins_Reporter::RESULT_FAIL
68: : Swift_Plugins_Reporter::RESULT_PASS)
69: );
70: }
71: }
72: }
73: