Added feature #15998: Create a new API to send mails based on SwiftMailer to replace...
[Packages/TYPO3.CMS.git] / typo3 / contrib / swiftmailer / classes / Swift / Plugins / Reporters / HitReporter.php
1 <?php
2
3 /*
4 * This file is part of SwiftMailer.
5 * (c) 2004-2009 Chris Corbyn
6 *
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
9 */
10
11 //@require 'Swift/Plugins/Reporter.php';
12 //@require 'Swift/Mime/Message.php';
13
14 /**
15 * A reporter which "collects" failures for the Reporter plugin.
16 * @package Swift
17 * @subpackage Plugins
18 * @author Chris Corbyn
19 */
20 class Swift_Plugins_Reporters_HitReporter implements Swift_Plugins_Reporter
21 {
22
23 /**
24 * The list of failures.
25 * @var array
26 * @access private
27 */
28 private $_failures = array();
29 private $_failures_cache = array();
30
31 /**
32 * Notifies this ReportNotifier that $address failed or succeeded.
33 * @param Swift_Mime_Message $message
34 * @param string $address
35 * @param int $result from {@link RESULT_PASS, RESULT_FAIL}
36 */
37 public function notify(Swift_Mime_Message $message, $address, $result)
38 {
39 if (self::RESULT_FAIL == $result && !isset($this->_failures_cache[$address]))
40 {
41 $this->_failures[] = $address;
42 $this->_failures_cache[$address] = true;
43 }
44 }
45
46 /**
47 * Get an array of addresses for which delivery failed.
48 * @return array
49 */
50 public function getFailedRecipients()
51 {
52 return $this->_failures;
53 }
54
55 /**
56 * Clear the buffer (empty the list).
57 */
58 public function clear()
59 {
60 $this->_failures = $this->_failures_cache = array();
61 }
62
63 }