[ Index ]

MailPress 7.2

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

title

Body

[close]

/mp-includes/composer/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/ -> NullTransport.php (source)

   1  <?php
   2  
   3  /*
   4   * This file is part of SwiftMailer.
   5   * (c) 2009 Fabien Potencier <fabien.potencier@gmail.com>
   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   * Pretends messages have been sent, but just ignores them.
  13   *
  14   * @author Fabien Potencier
  15   */
  16  class Swift_Transport_NullTransport implements Swift_Transport
  17  {
  18      /** The event dispatcher from the plugin API */
  19      private $eventDispatcher;
  20  
  21      /**
  22       * Constructor.
  23       */
  24      public function __construct(Swift_Events_EventDispatcher $eventDispatcher)
  25      {
  26          $this->eventDispatcher = $eventDispatcher;
  27      }
  28  
  29      /**
  30       * Tests if this Transport mechanism has started.
  31       *
  32       * @return bool
  33       */
  34      public function isStarted()
  35      {
  36          return true;
  37      }
  38  
  39      /**
  40       * Starts this Transport mechanism.
  41       */
  42      public function start()
  43      {
  44      }
  45  
  46      /**
  47       * Stops this Transport mechanism.
  48       */
  49      public function stop()
  50      {
  51      }
  52  
  53      /**
  54       * {@inheritdoc}
  55       */
  56      public function ping()
  57      {
  58          return true;
  59      }
  60  
  61      /**
  62       * Sends the given message.
  63       *
  64       * @param string[] $failedRecipients An array of failures by-reference
  65       *
  66       * @return int The number of sent emails
  67       */
  68      public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null)
  69      {
  70          if ($evt = $this->eventDispatcher->createSendEvent($this, $message)) {
  71              $this->eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed');
  72              if ($evt->bubbleCancelled()) {
  73                  return 0;
  74              }
  75          }
  76  
  77          if ($evt) {
  78              $evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS);
  79              $this->eventDispatcher->dispatchEvent($evt, 'sendPerformed');
  80          }
  81  
  82          $count = (
  83              count((array) $message->getTo())
  84              + count((array) $message->getCc())
  85              + count((array) $message->getBcc())
  86              );
  87  
  88          return $count;
  89      }
  90  
  91      /**
  92       * Register a plugin.
  93       */
  94      public function registerPlugin(Swift_Events_EventListener $plugin)
  95      {
  96          $this->eventDispatcher->bindEventListener($plugin);
  97      }
  98  }


Generated: Tue May 19 15:55:14 2020 Cross-referenced by PHPXref 0.7.1