TYPO3  7.6
vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer.php
Go to the documentation of this file.
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 
17 {
19  private $_transport;
20 
26  public function __construct(Swift_Transport $transport)
27  {
28  $this->_transport = $transport;
29  }
30 
38  public static function newInstance(Swift_Transport $transport)
39  {
40  return new self($transport);
41  }
42 
52  public function createMessage($service = 'message')
53  {
55  ->lookup('message.'.$service);
56  }
57 
74  public function send(Swift_Mime_Message $message, &$failedRecipients = null)
75  {
76  $failedRecipients = (array) $failedRecipients;
77 
78  if (!$this->_transport->isStarted()) {
79  $this->_transport->start();
80  }
81 
82  $sent = 0;
83 
84  try {
85  $sent = $this->_transport->send($message, $failedRecipients);
86  } catch (Swift_RfcComplianceException $e) {
87  foreach ($message->getTo() as $address => $name) {
88  $failedRecipients[] = $address;
89  }
90  }
91 
92  return $sent;
93  }
94 
101  {
102  $this->_transport->registerPlugin($plugin);
103  }
104 
110  public function getTransport()
111  {
112  return $this->_transport;
113  }
114 }