[ Index ]

MailPress 7.2

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

title

Body

[close]

/mp-includes/composer/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ -> Mailer.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   * Swift Mailer class.
  13   *
  14   * @author Chris Corbyn
  15   */
  16  class Swift_Mailer
  17  {
  18      /** The Transport used to send messages */
  19      private $transport;
  20  
  21      /**
  22       * Create a new Mailer using $transport for delivery.
  23       */
  24      public function __construct(Swift_Transport $transport)
  25      {
  26          $this->transport = $transport;
  27      }
  28  
  29      /**
  30       * Create a new class instance of one of the message services.
  31       *
  32       * For example 'mimepart' would create a 'message.mimepart' instance
  33       *
  34       * @param string $service
  35       *
  36       * @return object
  37       */
  38      public function createMessage($service = 'message')
  39      {
  40          return Swift_DependencyContainer::getInstance()
  41              ->lookup('message.'.$service);
  42      }
  43  
  44      /**
  45       * Send the given Message like it would be sent in a mail client.
  46       *
  47       * All recipients (with the exception of Bcc) will be able to see the other
  48       * recipients this message was sent to.
  49       *
  50       * Recipient/sender data will be retrieved from the Message object.
  51       *
  52       * The return value is the number of recipients who were accepted for
  53       * delivery.
  54       *
  55       * @param array $failedRecipients An array of failures by-reference
  56       *
  57       * @return int The number of successful recipients. Can be 0 which indicates failure
  58       */
  59      public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null)
  60      {
  61          $failedRecipients = (array) $failedRecipients;
  62  
  63          // FIXME: to be removed in 7.0 (as transport must now start itself on send)
  64          if (!$this->transport->isStarted()) {
  65              $this->transport->start();
  66          }
  67  
  68          $sent = 0;
  69  
  70          try {
  71              $sent = $this->transport->send($message, $failedRecipients);
  72          } catch (Swift_RfcComplianceException $e) {
  73              foreach ($message->getTo() as $address => $name) {
  74                  $failedRecipients[] = $address;
  75              }
  76          }
  77  
  78          return $sent;
  79      }
  80  
  81      /**
  82       * Register a plugin using a known unique key (e.g. myPlugin).
  83       */
  84      public function registerPlugin(Swift_Events_EventListener $plugin)
  85      {
  86          $this->transport->registerPlugin($plugin);
  87      }
  88  
  89      /**
  90       * The Transport used to send messages.
  91       *
  92       * @return Swift_Transport
  93       */
  94      public function getTransport()
  95      {
  96          return $this->transport;
  97      }
  98  }


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