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
|
|
|
* 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
|
|
|
* @param Swift_Events_EventDispatcher $eventDispatcher |
25
|
|
|
*/ |
26
|
1 |
|
public function __construct(Swift_Events_EventDispatcher $eventDispatcher) |
27
|
|
|
{ |
28
|
1 |
|
$this->_eventDispatcher = $eventDispatcher; |
29
|
1 |
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Tests if this Transport mechanism has started. |
33
|
|
|
* |
34
|
|
|
* @return bool |
35
|
|
|
*/ |
36
|
|
|
public function isStarted() |
37
|
|
|
{ |
38
|
|
|
return true; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Starts this Transport mechanism. |
43
|
|
|
*/ |
44
|
|
|
public function start() |
45
|
|
|
{ |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Stops this Transport mechanism. |
50
|
|
|
*/ |
51
|
|
|
public function stop() |
52
|
|
|
{ |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Check if this Transport mechanism is alive. |
57
|
|
|
* |
58
|
|
|
* If a Transport mechanism session is no longer functional, the method |
59
|
|
|
* returns FALSE. It is the responsibility of the developer to handle this |
60
|
|
|
* case and restart the Transport mechanism manually. |
61
|
|
|
* |
62
|
|
|
* @example |
63
|
|
|
* |
64
|
|
|
* if (!$transport->ping()) { |
65
|
|
|
* $transport->stop(); |
66
|
|
|
* $transport->start(); |
67
|
|
|
* } |
68
|
|
|
* |
69
|
|
|
* The Transport mechanism will be started, if it is not already. |
70
|
|
|
* |
71
|
|
|
* It is undefined if the Transport mechanism attempts to restart as long as |
72
|
|
|
* the return value reflects whether the mechanism is now functional. |
73
|
|
|
* |
74
|
|
|
* @return bool TRUE if the transport is alive |
75
|
|
|
*/ |
76
|
|
|
public function ping() |
77
|
|
|
{ |
78
|
|
|
return true; |
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 emails |
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
|
|
|
if ($evt) { |
101
|
|
|
$evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS); |
102
|
|
|
$this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed'); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
$count = ( |
106
|
|
|
count((array)$message->getTo()) |
107
|
|
|
+ count((array)$message->getCc()) |
108
|
|
|
+ count((array)$message->getBcc()) |
109
|
|
|
); |
110
|
|
|
|
111
|
|
|
return $count; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* Register a plugin. |
116
|
|
|
* |
117
|
|
|
* @param Swift_Events_EventListener $plugin |
118
|
|
|
*/ |
119
|
|
|
public function registerPlugin(Swift_Events_EventListener $plugin) |
120
|
|
|
{ |
121
|
|
|
$this->_eventDispatcher->bindEventListener($plugin); |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
|
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.