TYPO3  7.6
MemorySpool.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of SwiftMailer.
5  * (c) 2011 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 
17 {
18  protected $messages = array();
19 
25  public function isStarted()
26  {
27  return true;
28  }
29 
33  public function start()
34  {
35  }
36 
40  public function stop()
41  {
42  }
43 
51  public function queueMessage(Swift_Mime_Message $message)
52  {
53  //clone the message to make sure it is not changed while in the queue
54  $this->messages[] = clone $message;
55 
56  return true;
57  }
58 
67  public function flushQueue(Swift_Transport $transport, &$failedRecipients = null)
68  {
69  if (!$this->messages) {
70  return 0;
71  }
72 
73  if (!$transport->isStarted()) {
74  $transport->start();
75  }
76 
77  $count = 0;
78  while ($message = array_pop($this->messages)) {
79  $count += $transport->send($message, $failedRecipients);
80  }
81 
82  return $count;
83  }
84 }