1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of SwiftMailer. |
5
|
|
|
* (c) 2009 Fabien Potencier <[email protected]> |
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
|
|
|
* Stores Messages in a queue. |
13
|
|
|
* |
14
|
|
|
* @author Fabien Potencier |
15
|
|
|
*/ |
16
|
|
|
class Swift_Transport_SpoolTransport implements Swift_Transport |
|
|
|
|
17
|
|
|
{ |
18
|
|
|
/** The spool instance */ |
19
|
|
|
private $_spool; |
20
|
|
|
|
21
|
|
|
/** The event dispatcher from the plugin API */ |
22
|
|
|
private $_eventDispatcher; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Constructor. |
26
|
|
|
*/ |
27
|
1 |
|
public function __construct(Swift_Events_EventDispatcher $eventDispatcher, Swift_Spool $spool = null) |
28
|
|
|
{ |
29
|
1 |
|
$this->_eventDispatcher = $eventDispatcher; |
30
|
1 |
|
$this->_spool = $spool; |
31
|
1 |
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Sets the spool object. |
35
|
|
|
* |
36
|
|
|
* @param Swift_Spool $spool |
37
|
|
|
* |
38
|
|
|
* @return $this |
39
|
|
|
*/ |
40
|
|
|
public function setSpool(Swift_Spool $spool) |
41
|
|
|
{ |
42
|
|
|
$this->_spool = $spool; |
43
|
|
|
|
44
|
|
|
return $this; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Get the spool object. |
49
|
|
|
* |
50
|
|
|
* @return Swift_Spool |
51
|
|
|
*/ |
52
|
|
|
public function getSpool() |
53
|
|
|
{ |
54
|
|
|
return $this->_spool; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Tests if this Transport mechanism has started. |
59
|
|
|
* |
60
|
|
|
* @return bool |
61
|
|
|
*/ |
62
|
|
|
public function isStarted() |
63
|
|
|
{ |
64
|
|
|
return true; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Starts this Transport mechanism. |
69
|
|
|
*/ |
70
|
|
|
public function start() |
71
|
|
|
{ |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Stops this Transport mechanism. |
76
|
|
|
*/ |
77
|
|
|
public function stop() |
78
|
|
|
{ |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Sends the given message. |
83
|
|
|
* |
84
|
|
|
* @param Swift_Mime_Message $message |
85
|
|
|
* @param string[] $failedRecipients An array of failures by-reference |
86
|
|
|
* |
87
|
|
|
* @return int The number of sent e-mail's |
88
|
|
|
*/ |
89
|
|
|
public function send(Swift_Mime_Message $message, &$failedRecipients = null) |
90
|
|
|
{ |
91
|
|
|
$evt = $this->_eventDispatcher->createSendEvent($this, $message); |
92
|
|
|
if ($evt) { |
93
|
|
|
|
94
|
|
|
$this->_eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); |
95
|
|
|
if ($evt->bubbleCancelled()) { |
96
|
|
|
return 0; |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
$success = $this->_spool->queueMessage($message); |
101
|
|
|
|
102
|
|
|
if ($evt) { |
103
|
|
|
$evt->setResult($success ? Swift_Events_SendEvent::RESULT_SPOOLED : Swift_Events_SendEvent::RESULT_FAILED); |
104
|
|
|
$this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed'); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
return 1; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* Register a plugin. |
112
|
|
|
* |
113
|
|
|
* @param Swift_Events_EventListener $plugin |
114
|
|
|
*/ |
115
|
|
|
public function registerPlugin(Swift_Events_EventListener $plugin) |
116
|
|
|
{ |
117
|
|
|
$this->_eventDispatcher->bindEventListener($plugin); |
118
|
|
|
} |
119
|
|
|
} |
120
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.