|
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
|
|
|
* Sends the given message. |
|
57
|
|
|
* |
|
58
|
|
|
* @param Swift_Mime_Message $message |
|
59
|
|
|
* @param string[] $failedRecipients An array of failures by-reference |
|
60
|
|
|
* |
|
61
|
|
|
* @return int The number of sent emails |
|
62
|
|
|
*/ |
|
63
|
|
|
public function send(Swift_Mime_Message $message, &$failedRecipients = null) |
|
64
|
|
|
{ |
|
65
|
|
|
$evt = $this->_eventDispatcher->createSendEvent($this, $message); |
|
66
|
|
|
if ($evt) { |
|
67
|
|
|
|
|
68
|
|
|
$this->_eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); |
|
69
|
|
|
if ($evt->bubbleCancelled()) { |
|
70
|
|
|
return 0; |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
if ($evt) { |
|
75
|
|
|
$evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS); |
|
76
|
|
|
$this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed'); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
$count = ( |
|
80
|
|
|
count((array)$message->getTo()) |
|
81
|
|
|
+ count((array)$message->getCc()) |
|
82
|
|
|
+ count((array)$message->getBcc()) |
|
83
|
|
|
); |
|
84
|
|
|
|
|
85
|
|
|
return $count; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* Register a plugin. |
|
90
|
|
|
* |
|
91
|
|
|
* @param Swift_Events_EventListener $plugin |
|
92
|
|
|
*/ |
|
93
|
|
|
public function registerPlugin(Swift_Events_EventListener $plugin) |
|
94
|
|
|
{ |
|
95
|
|
|
$this->_eventDispatcher->bindEventListener($plugin); |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|
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.