[ Index ]

MailPress 544

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]     [ Statistics ]    

title

Body

[close]

/mp-includes/Swiftmailer/classes/Swift/Plugins/ -> ReporterPlugin.php (source)

   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  /**
  12   * Does real time reporting of pass/fail for each recipient.
  13   *
  14   * @author Chris Corbyn
  15   */
  16  class Swift_Plugins_ReporterPlugin implements Swift_Events_SendListener
  17  {
  18      /**
  19       * The reporter backend which takes notifications.
  20       *
  21       * @var Swift_Plugins_Reporter
  22       */
  23      private $_reporter;
  24  
  25      /**
  26       * Create a new ReporterPlugin using $reporter.
  27       *
  28       * @param Swift_Plugins_Reporter $reporter
  29       */
  30      public function __construct(Swift_Plugins_Reporter $reporter)
  31      {
  32          $this->_reporter = $reporter;
  33      }
  34  
  35      /**
  36       * Not used.
  37       */
  38      public function beforeSendPerformed(Swift_Events_SendEvent $evt)
  39      {
  40      }
  41  
  42      /**
  43       * Invoked immediately after the Message is sent.
  44       *
  45       * @param Swift_Events_SendEvent $evt
  46       */
  47      public function sendPerformed(Swift_Events_SendEvent $evt)
  48      {
  49          $message = $evt->getMessage();
  50          $failures = array_flip($evt->getFailedRecipients());
  51          foreach ((array) $message->getTo() as $address => $null) {
  52              $this->_reporter->notify(
  53                  $message, $address, (array_key_exists($address, $failures)
  54                  ? Swift_Plugins_Reporter::RESULT_FAIL
  55                  : Swift_Plugins_Reporter::RESULT_PASS)
  56                  );
  57          }
  58          foreach ((array) $message->getCc() as $address => $null) {
  59              $this->_reporter->notify(
  60                  $message, $address, (array_key_exists($address, $failures)
  61                  ? Swift_Plugins_Reporter::RESULT_FAIL
  62                  : Swift_Plugins_Reporter::RESULT_PASS)
  63                  );
  64          }
  65          foreach ((array) $message->getBcc() 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)
  70                  );
  71          }
  72      }
  73  }


Generated: Thu Apr 28 18:38:52 2016 Cross-referenced by PHPXref 0.7.1