|
TYPO3 API
SVNRelease
|
00001 <?php 00002 00003 /* 00004 * This file is part of SwiftMailer. 00005 * (c) 2004-2009 Chris Corbyn 00006 * 00007 * For the full copyright and license information, please view the LICENSE 00008 * file that was distributed with this source code. 00009 */ 00010 00011 //@require 'Swift/Events/SendListener.php'; 00012 //@require 'Swift/Events/SendEvent.php'; 00013 //@require 'Swift/Plugins/Reporter.php'; 00014 00015 /** 00016 * Does real time reporting of pass/fail for each recipient. 00017 * @package Swift 00018 * @subpackage Plugins 00019 * @author Chris Corbyn 00020 */ 00021 class Swift_Plugins_ReporterPlugin 00022 implements Swift_Events_SendListener 00023 { 00024 00025 /** 00026 * The reporter backend which takes notifications. 00027 * @var Swift_Plugin_Reporter 00028 * @access private 00029 */ 00030 private $_reporter; 00031 00032 /** 00033 * Create a new ReporterPlugin using $reporter. 00034 * @param Swift_Plugins_Reporter $reporter 00035 */ 00036 public function __construct(Swift_Plugins_Reporter $reporter) 00037 { 00038 $this->_reporter = $reporter; 00039 } 00040 00041 /** 00042 * Not used. 00043 */ 00044 public function beforeSendPerformed(Swift_Events_SendEvent $evt) 00045 { 00046 } 00047 00048 /** 00049 * Invoked immediately after the Message is sent. 00050 * @param Swift_Events_SendEvent $evt 00051 */ 00052 public function sendPerformed(Swift_Events_SendEvent $evt) 00053 { 00054 $message = $evt->getMessage(); 00055 $failures = array_flip($evt->getFailedRecipients()); 00056 foreach ((array) $message->getTo() as $address => $null) 00057 { 00058 $this->_reporter->notify( 00059 $message, $address, (array_key_exists($address, $failures) 00060 ? Swift_Plugins_Reporter::RESULT_FAIL 00061 : Swift_Plugins_Reporter::RESULT_PASS) 00062 ); 00063 } 00064 foreach ((array) $message->getCc() as $address => $null) 00065 { 00066 $this->_reporter->notify( 00067 $message, $address, (array_key_exists($address, $failures) 00068 ? Swift_Plugins_Reporter::RESULT_FAIL 00069 : Swift_Plugins_Reporter::RESULT_PASS) 00070 ); 00071 } 00072 foreach ((array) $message->getBcc() as $address => $null) 00073 { 00074 $this->_reporter->notify( 00075 $message, $address, (array_key_exists($address, $failures) 00076 ? Swift_Plugins_Reporter::RESULT_FAIL 00077 : Swift_Plugins_Reporter::RESULT_PASS) 00078 ); 00079 } 00080 } 00081 00082 }
1.8.0