summaryrefslogtreecommitdiff
path: root/vendor/swiftmailer/classes/Swift/Plugins
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/swiftmailer/classes/Swift/Plugins')
-rw-r--r--vendor/swiftmailer/classes/Swift/Plugins/AntiFloodPlugin.php141
-rw-r--r--vendor/swiftmailer/classes/Swift/Plugins/BandwidthMonitorPlugin.php164
-rw-r--r--vendor/swiftmailer/classes/Swift/Plugins/Decorator/Replacements.php31
-rw-r--r--vendor/swiftmailer/classes/Swift/Plugins/DecoratorPlugin.php207
-rw-r--r--vendor/swiftmailer/classes/Swift/Plugins/ImpersonatePlugin.php68
-rw-r--r--vendor/swiftmailer/classes/Swift/Plugins/Logger.php36
-rw-r--r--vendor/swiftmailer/classes/Swift/Plugins/LoggerPlugin.php141
-rw-r--r--vendor/swiftmailer/classes/Swift/Plugins/Loggers/ArrayLogger.php72
-rw-r--r--vendor/swiftmailer/classes/Swift/Plugins/Loggers/EchoLogger.php58
-rw-r--r--vendor/swiftmailer/classes/Swift/Plugins/MessageLogger.php75
-rw-r--r--vendor/swiftmailer/classes/Swift/Plugins/Pop/Pop3Connection.php31
-rw-r--r--vendor/swiftmailer/classes/Swift/Plugins/Pop/Pop3Exception.php27
-rw-r--r--vendor/swiftmailer/classes/Swift/Plugins/PopBeforeSmtpPlugin.php274
-rw-r--r--vendor/swiftmailer/classes/Swift/Plugins/RedirectingPlugin.php205
-rw-r--r--vendor/swiftmailer/classes/Swift/Plugins/Reporter.php32
-rw-r--r--vendor/swiftmailer/classes/Swift/Plugins/ReporterPlugin.php73
-rw-r--r--vendor/swiftmailer/classes/Swift/Plugins/Reporters/HitReporter.php59
-rw-r--r--vendor/swiftmailer/classes/Swift/Plugins/Reporters/HtmlReporter.php39
-rw-r--r--vendor/swiftmailer/classes/Swift/Plugins/Sleeper.php24
-rw-r--r--vendor/swiftmailer/classes/Swift/Plugins/ThrottlerPlugin.php200
-rw-r--r--vendor/swiftmailer/classes/Swift/Plugins/Timer.php24
21 files changed, 1981 insertions, 0 deletions
diff --git a/vendor/swiftmailer/classes/Swift/Plugins/AntiFloodPlugin.php b/vendor/swiftmailer/classes/Swift/Plugins/AntiFloodPlugin.php
new file mode 100644
index 00000000..28f3a817
--- /dev/null
+++ b/vendor/swiftmailer/classes/Swift/Plugins/AntiFloodPlugin.php
@@ -0,0 +1,141 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Reduces network flooding when sending large amounts of mail.
+ *
+ * @author Chris Corbyn
+ */
+class Swift_Plugins_AntiFloodPlugin implements Swift_Events_SendListener, Swift_Plugins_Sleeper
+{
+ /**
+ * The number of emails to send before restarting Transport.
+ *
+ * @var int
+ */
+ private $_threshold;
+
+ /**
+ * The number of seconds to sleep for during a restart.
+ *
+ * @var int
+ */
+ private $_sleep;
+
+ /**
+ * The internal counter.
+ *
+ * @var int
+ */
+ private $_counter = 0;
+
+ /**
+ * The Sleeper instance for sleeping.
+ *
+ * @var Swift_Plugins_Sleeper
+ */
+ private $_sleeper;
+
+ /**
+ * Create a new AntiFloodPlugin with $threshold and $sleep time.
+ *
+ * @param int $threshold
+ * @param int $sleep time
+ * @param Swift_Plugins_Sleeper $sleeper (not needed really)
+ */
+ public function __construct($threshold = 99, $sleep = 0, Swift_Plugins_Sleeper $sleeper = null)
+ {
+ $this->setThreshold($threshold);
+ $this->setSleepTime($sleep);
+ $this->_sleeper = $sleeper;
+ }
+
+ /**
+ * Set the number of emails to send before restarting.
+ *
+ * @param int $threshold
+ */
+ public function setThreshold($threshold)
+ {
+ $this->_threshold = $threshold;
+ }
+
+ /**
+ * Get the number of emails to send before restarting.
+ *
+ * @return int
+ */
+ public function getThreshold()
+ {
+ return $this->_threshold;
+ }
+
+ /**
+ * Set the number of seconds to sleep for during a restart.
+ *
+ * @param int $sleep time
+ */
+ public function setSleepTime($sleep)
+ {
+ $this->_sleep = $sleep;
+ }
+
+ /**
+ * Get the number of seconds to sleep for during a restart.
+ *
+ * @return int
+ */
+ public function getSleepTime()
+ {
+ return $this->_sleep;
+ }
+
+ /**
+ * Invoked immediately before the Message is sent.
+ *
+ * @param Swift_Events_SendEvent $evt
+ */
+ public function beforeSendPerformed(Swift_Events_SendEvent $evt)
+ {
+ }
+
+ /**
+ * Invoked immediately after the Message is sent.
+ *
+ * @param Swift_Events_SendEvent $evt
+ */
+ public function sendPerformed(Swift_Events_SendEvent $evt)
+ {
+ ++$this->_counter;
+ if ($this->_counter >= $this->_threshold) {
+ $transport = $evt->getTransport();
+ $transport->stop();
+ if ($this->_sleep) {
+ $this->sleep($this->_sleep);
+ }
+ $transport->start();
+ $this->_counter = 0;
+ }
+ }
+
+ /**
+ * Sleep for $seconds.
+ *
+ * @param int $seconds
+ */
+ public function sleep($seconds)
+ {
+ if (isset($this->_sleeper)) {
+ $this->_sleeper->sleep($seconds);
+ } else {
+ sleep($seconds);
+ }
+ }
+}
diff --git a/vendor/swiftmailer/classes/Swift/Plugins/BandwidthMonitorPlugin.php b/vendor/swiftmailer/classes/Swift/Plugins/BandwidthMonitorPlugin.php
new file mode 100644
index 00000000..af1701a0
--- /dev/null
+++ b/vendor/swiftmailer/classes/Swift/Plugins/BandwidthMonitorPlugin.php
@@ -0,0 +1,164 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Reduces network flooding when sending large amounts of mail.
+ *
+ * @author Chris Corbyn
+ */
+class Swift_Plugins_BandwidthMonitorPlugin implements Swift_Events_SendListener, Swift_Events_CommandListener, Swift_Events_ResponseListener, Swift_InputByteStream
+{
+ /**
+ * The outgoing traffic counter.
+ *
+ * @var int
+ */
+ private $_out = 0;
+
+ /**
+ * The incoming traffic counter.
+ *
+ * @var int
+ */
+ private $_in = 0;
+
+ /** Bound byte streams */
+ private $_mirrors = array();
+
+ /**
+ * Not used.
+ */
+ public function beforeSendPerformed(Swift_Events_SendEvent $evt)
+ {
+ }
+
+ /**
+ * Invoked immediately after the Message is sent.
+ *
+ * @param Swift_Events_SendEvent $evt
+ */
+ public function sendPerformed(Swift_Events_SendEvent $evt)
+ {
+ $message = $evt->getMessage();
+ $message->toByteStream($this);
+ }
+
+ /**
+ * Invoked immediately following a command being sent.
+ *
+ * @param Swift_Events_CommandEvent $evt
+ */
+ public function commandSent(Swift_Events_CommandEvent $evt)
+ {
+ $command = $evt->getCommand();
+ $this->_out += strlen($command);
+ }
+
+ /**
+ * Invoked immediately following a response coming back.
+ *
+ * @param Swift_Events_ResponseEvent $evt
+ */
+ public function responseReceived(Swift_Events_ResponseEvent $evt)
+ {
+ $response = $evt->getResponse();
+ $this->_in += strlen($response);
+ }
+
+ /**
+ * Called when a message is sent so that the outgoing counter can be increased.
+ *
+ * @param string $bytes
+ */
+ public function write($bytes)
+ {
+ $this->_out += strlen($bytes);
+ foreach ($this->_mirrors as $stream) {
+ $stream->write($bytes);
+ }
+ }
+
+ /**
+ * Not used.
+ */
+ public function commit()
+ {
+ }
+
+ /**
+ * Attach $is to this stream.
+ *
+ * The stream acts as an observer, receiving all data that is written.
+ * All {@link write()} and {@link flushBuffers()} operations will be mirrored.
+ *
+ * @param Swift_InputByteStream $is
+ */
+ public function bind(Swift_InputByteStream $is)
+ {
+ $this->_mirrors[] = $is;
+ }
+
+ /**
+ * Remove an already bound stream.
+ *
+ * If $is is not bound, no errors will be raised.
+ * If the stream currently has any buffered data it will be written to $is
+ * before unbinding occurs.
+ *
+ * @param Swift_InputByteStream $is
+ */
+ public function unbind(Swift_InputByteStream $is)
+ {
+ foreach ($this->_mirrors as $k => $stream) {
+ if ($is === $stream) {
+ unset($this->_mirrors[$k]);
+ }
+ }
+ }
+
+ /**
+ * Not used.
+ */
+ public function flushBuffers()
+ {
+ foreach ($this->_mirrors as $stream) {
+ $stream->flushBuffers();
+ }
+ }
+
+ /**
+ * Get the total number of bytes sent to the server.
+ *
+ * @return int
+ */
+ public function getBytesOut()
+ {
+ return $this->_out;
+ }
+
+ /**
+ * Get the total number of bytes received from the server.
+ *
+ * @return int
+ */
+ public function getBytesIn()
+ {
+ return $this->_in;
+ }
+
+ /**
+ * Reset the internal counters to zero.
+ */
+ public function reset()
+ {
+ $this->_out = 0;
+ $this->_in = 0;
+ }
+}
diff --git a/vendor/swiftmailer/classes/Swift/Plugins/Decorator/Replacements.php b/vendor/swiftmailer/classes/Swift/Plugins/Decorator/Replacements.php
new file mode 100644
index 00000000..86184339
--- /dev/null
+++ b/vendor/swiftmailer/classes/Swift/Plugins/Decorator/Replacements.php
@@ -0,0 +1,31 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Allows customization of Messages on-the-fly.
+ *
+ * @author Chris Corbyn
+ */
+interface Swift_Plugins_Decorator_Replacements
+{
+ /**
+ * Return the array of replacements for $address.
+ *
+ * This method is invoked once for every single recipient of a message.
+ *
+ * If no replacements can be found, an empty value (NULL) should be returned
+ * and no replacements will then be made on the message.
+ *
+ * @param string $address
+ *
+ * @return array
+ */
+ public function getReplacementsFor($address);
+}
diff --git a/vendor/swiftmailer/classes/Swift/Plugins/DecoratorPlugin.php b/vendor/swiftmailer/classes/Swift/Plugins/DecoratorPlugin.php
new file mode 100644
index 00000000..e1aaebe9
--- /dev/null
+++ b/vendor/swiftmailer/classes/Swift/Plugins/DecoratorPlugin.php
@@ -0,0 +1,207 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Allows customization of Messages on-the-fly.
+ *
+ * @author Chris Corbyn
+ * @author Fabien Potencier
+ */
+class Swift_Plugins_DecoratorPlugin implements Swift_Events_SendListener, Swift_Plugins_Decorator_Replacements
+{
+ /** The replacement map */
+ private $_replacements;
+
+ /** The body as it was before replacements */
+ private $_originalBody;
+
+ /** The original headers of the message, before replacements */
+ private $_originalHeaders = array();
+
+ /** Bodies of children before they are replaced */
+ private $_originalChildBodies = array();
+
+ /** The Message that was last replaced */
+ private $_lastMessage;
+
+ /**
+ * Create a new DecoratorPlugin with $replacements.
+ *
+ * The $replacements can either be an associative array, or an implementation
+ * of {@link Swift_Plugins_Decorator_Replacements}.
+ *
+ * When using an array, it should be of the form:
+ * <code>
+ * $replacements = array(
+ * "address1@domain.tld" => array("{a}" => "b", "{c}" => "d"),
+ * "address2@domain.tld" => array("{a}" => "x", "{c}" => "y")
+ * )
+ * </code>
+ *
+ * When using an instance of {@link Swift_Plugins_Decorator_Replacements},
+ * the object should return just the array of replacements for the address
+ * given to {@link Swift_Plugins_Decorator_Replacements::getReplacementsFor()}.
+ *
+ * @param mixed $replacements Array or Swift_Plugins_Decorator_Replacements
+ */
+ public function __construct($replacements)
+ {
+ $this->setReplacements($replacements);
+ }
+
+ /**
+ * Sets replacements.
+ *
+ * @param mixed $replacements Array or Swift_Plugins_Decorator_Replacements
+ *
+ * @see __construct()
+ */
+ public function setReplacements($replacements)
+ {
+ if (!($replacements instanceof Swift_Plugins_Decorator_Replacements)) {
+ $this->_replacements = (array) $replacements;
+ } else {
+ $this->_replacements = $replacements;
+ }
+ }
+
+ /**
+ * Invoked immediately before the Message is sent.
+ *
+ * @param Swift_Events_SendEvent $evt
+ */
+ public function beforeSendPerformed(Swift_Events_SendEvent $evt)
+ {
+ $message = $evt->getMessage();
+ $this->_restoreMessage($message);
+ $to = array_keys($message->getTo());
+ $address = array_shift($to);
+ if ($replacements = $this->getReplacementsFor($address)) {
+ $body = $message->getBody();
+ $search = array_keys($replacements);
+ $replace = array_values($replacements);
+ $bodyReplaced = str_replace(
+ $search, $replace, $body
+ );
+ if ($body != $bodyReplaced) {
+ $this->_originalBody = $body;
+ $message->setBody($bodyReplaced);
+ }
+
+ foreach ($message->getHeaders()->getAll() as $header) {
+ $body = $header->getFieldBodyModel();
+ $count = 0;
+ if (is_array($body)) {
+ $bodyReplaced = array();
+ foreach ($body as $key => $value) {
+ $count1 = 0;
+ $count2 = 0;
+ $key = is_string($key) ? str_replace($search, $replace, $key, $count1) : $key;
+ $value = is_string($value) ? str_replace($search, $replace, $value, $count2) : $value;
+ $bodyReplaced[$key] = $value;
+
+ if (!$count && ($count1 || $count2)) {
+ $count = 1;
+ }
+ }
+ } else {
+ $bodyReplaced = str_replace($search, $replace, $body, $count);
+ }
+
+ if ($count) {
+ $this->_originalHeaders[$header->getFieldName()] = $body;
+ $header->setFieldBodyModel($bodyReplaced);
+ }
+ }
+
+ $children = (array) $message->getChildren();
+ foreach ($children as $child) {
+ list($type, ) = sscanf($child->getContentType(), '%[^/]/%s');
+ if ('text' == $type) {
+ $body = $child->getBody();
+ $bodyReplaced = str_replace(
+ $search, $replace, $body
+ );
+ if ($body != $bodyReplaced) {
+ $child->setBody($bodyReplaced);
+ $this->_originalChildBodies[$child->getId()] = $body;
+ }
+ }
+ }
+ $this->_lastMessage = $message;
+ }
+ }
+
+ /**
+ * Find a map of replacements for the address.
+ *
+ * If this plugin was provided with a delegate instance of
+ * {@link Swift_Plugins_Decorator_Replacements} then the call will be
+ * delegated to it. Otherwise, it will attempt to find the replacements
+ * from the array provided in the constructor.
+ *
+ * If no replacements can be found, an empty value (NULL) is returned.
+ *
+ * @param string $address
+ *
+ * @return array
+ */
+ public function getReplacementsFor($address)
+ {
+ if ($this->_replacements instanceof Swift_Plugins_Decorator_Replacements) {
+ return $this->_replacements->getReplacementsFor($address);
+ } else {
+ return isset($this->_replacements[$address])
+ ? $this->_replacements[$address]
+ : null
+ ;
+ }
+ }
+
+ /**
+ * Invoked immediately after the Message is sent.
+ *
+ * @param Swift_Events_SendEvent $evt
+ */
+ public function sendPerformed(Swift_Events_SendEvent $evt)
+ {
+ $this->_restoreMessage($evt->getMessage());
+ }
+
+ /** Restore a changed message back to its original state */
+ private function _restoreMessage(Swift_Mime_Message $message)
+ {
+ if ($this->_lastMessage === $message) {
+ if (isset($this->_originalBody)) {
+ $message->setBody($this->_originalBody);
+ $this->_originalBody = null;
+ }
+ if (!empty($this->_originalHeaders)) {
+ foreach ($message->getHeaders()->getAll() as $header) {
+ if (array_key_exists($header->getFieldName(), $this->_originalHeaders)) {
+ $header->setFieldBodyModel($this->_originalHeaders[$header->getFieldName()]);
+ }
+ }
+ $this->_originalHeaders = array();
+ }
+ if (!empty($this->_originalChildBodies)) {
+ $children = (array) $message->getChildren();
+ foreach ($children as $child) {
+ $id = $child->getId();
+ if (array_key_exists($id, $this->_originalChildBodies)) {
+ $child->setBody($this->_originalChildBodies[$id]);
+ }
+ }
+ $this->_originalChildBodies = array();
+ }
+ $this->_lastMessage = null;
+ }
+ }
+}
diff --git a/vendor/swiftmailer/classes/Swift/Plugins/ImpersonatePlugin.php b/vendor/swiftmailer/classes/Swift/Plugins/ImpersonatePlugin.php
new file mode 100644
index 00000000..e2999490
--- /dev/null
+++ b/vendor/swiftmailer/classes/Swift/Plugins/ImpersonatePlugin.php
@@ -0,0 +1,68 @@
+<?php
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2009 Fabien Potencier
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Replaces the sender of a message.
+ *
+ * @author Arjen Brouwer
+ */
+class Swift_Plugins_ImpersonatePlugin implements Swift_Events_SendListener
+{
+ /**
+ * The sender to impersonate.
+ *
+ * @var String
+ */
+ private $_sender;
+
+ /**
+ * Create a new ImpersonatePlugin to impersonate $sender.
+ *
+ * @param string $sender address
+ */
+ public function __construct($sender)
+ {
+ $this->_sender = $sender;
+ }
+
+ /**
+ * Invoked immediately before the Message is sent.
+ *
+ * @param Swift_Events_SendEvent $evt
+ */
+ public function beforeSendPerformed(Swift_Events_SendEvent $evt)
+ {
+ $message = $evt->getMessage();
+ $headers = $message->getHeaders();
+
+ // save current recipients
+ $headers->addPathHeader('X-Swift-Return-Path', $message->getReturnPath());
+
+ // replace them with the one to send to
+ $message->setReturnPath($this->_sender);
+ }
+
+ /**
+ * Invoked immediately after the Message is sent.
+ *
+ * @param Swift_Events_SendEvent $evt
+ */
+ public function sendPerformed(Swift_Events_SendEvent $evt)
+ {
+ $message = $evt->getMessage();
+
+ // restore original headers
+ $headers = $message->getHeaders();
+
+ if ($headers->has('X-Swift-Return-Path')) {
+ $message->setReturnPath($headers->get('X-Swift-Return-Path')->getAddress());
+ $headers->removeAll('X-Swift-Return-Path');
+ }
+ }
+}
diff --git a/vendor/swiftmailer/classes/Swift/Plugins/Logger.php b/vendor/swiftmailer/classes/Swift/Plugins/Logger.php
new file mode 100644
index 00000000..915e7206
--- /dev/null
+++ b/vendor/swiftmailer/classes/Swift/Plugins/Logger.php
@@ -0,0 +1,36 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Logs events in the Transport system.
+ *
+ * @author Chris Corbyn
+ */
+interface Swift_Plugins_Logger
+{
+ /**
+ * Add a log entry.
+ *
+ * @param string $entry
+ */
+ public function add($entry);
+
+ /**
+ * Clear the log contents.
+ */
+ public function clear();
+
+ /**
+ * Get this log as a string.
+ *
+ * @return string
+ */
+ public function dump();
+}
diff --git a/vendor/swiftmailer/classes/Swift/Plugins/LoggerPlugin.php b/vendor/swiftmailer/classes/Swift/Plugins/LoggerPlugin.php
new file mode 100644
index 00000000..98e59052
--- /dev/null
+++ b/vendor/swiftmailer/classes/Swift/Plugins/LoggerPlugin.php
@@ -0,0 +1,141 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Does real time logging of Transport level information.
+ *
+ * @author Chris Corbyn
+ */
+class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_Events_ResponseListener, Swift_Events_TransportChangeListener, Swift_Events_TransportExceptionListener, Swift_Plugins_Logger
+{
+ /** The logger which is delegated to */
+ private $_logger;
+
+ /**
+ * Create a new LoggerPlugin using $logger.
+ *
+ * @param Swift_Plugins_Logger $logger
+ */
+ public function __construct(Swift_Plugins_Logger $logger)
+ {
+ $this->_logger = $logger;
+ }
+
+ /**
+ * Add a log entry.
+ *
+ * @param string $entry
+ */
+ public function add($entry)
+ {
+ $this->_logger->add($entry);
+ }
+
+ /**
+ * Clear the log contents.
+ */
+ public function clear()
+ {
+ $this->_logger->clear();
+ }
+
+ /**
+ * Get this log as a string.
+ *
+ * @return string
+ */
+ public function dump()
+ {
+ return $this->_logger->dump();
+ }
+
+ /**
+ * Invoked immediately following a command being sent.
+ *
+ * @param Swift_Events_CommandEvent $evt
+ */
+ public function commandSent(Swift_Events_CommandEvent $evt)
+ {
+ $command = $evt->getCommand();
+ $this->_logger->add(sprintf(">> %s", $command));
+ }
+
+ /**
+ * Invoked immediately following a response coming back.
+ *
+ * @param Swift_Events_ResponseEvent $evt
+ */
+ public function responseReceived(Swift_Events_ResponseEvent $evt)
+ {
+ $response = $evt->getResponse();
+ $this->_logger->add(sprintf("<< %s", $response));
+ }
+
+ /**
+ * Invoked just before a Transport is started.
+ *
+ * @param Swift_Events_TransportChangeEvent $evt
+ */
+ public function beforeTransportStarted(Swift_Events_TransportChangeEvent $evt)
+ {
+ $transportName = get_class($evt->getSource());
+ $this->_logger->add(sprintf("++ Starting %s", $transportName));
+ }
+
+ /**
+ * Invoked immediately after the Transport is started.
+ *
+ * @param Swift_Events_TransportChangeEvent $evt
+ */
+ public function transportStarted(Swift_Events_TransportChangeEvent $evt)
+ {
+ $transportName = get_class($evt->getSource());
+ $this->_logger->add(sprintf("++ %s started", $transportName));
+ }
+
+ /**
+ * Invoked just before a Transport is stopped.
+ *
+ * @param Swift_Events_TransportChangeEvent $evt
+ */
+ public function beforeTransportStopped(Swift_Events_TransportChangeEvent $evt)
+ {
+ $transportName = get_class($evt->getSource());
+ $this->_logger->add(sprintf("++ Stopping %s", $transportName));
+ }
+
+ /**
+ * Invoked immediately after the Transport is stopped.
+ *
+ * @param Swift_Events_TransportChangeEvent $evt
+ */
+ public function transportStopped(Swift_Events_TransportChangeEvent $evt)
+ {
+ $transportName = get_class($evt->getSource());
+ $this->_logger->add(sprintf("++ %s stopped", $transportName));
+ }
+
+ /**
+ * Invoked as a TransportException is thrown in the Transport system.
+ *
+ * @param Swift_Events_TransportExceptionEvent $evt
+ */
+ public function exceptionThrown(Swift_Events_TransportExceptionEvent $evt)
+ {
+ $e = $evt->getException();
+ $message = $e->getMessage();
+ $this->_logger->add(sprintf("!! %s", $message));
+ $message .= PHP_EOL;
+ $message .= 'Log data:' . PHP_EOL;
+ $message .= $this->_logger->dump();
+ $evt->cancelBubble();
+ throw new Swift_TransportException($message);
+ }
+}
diff --git a/vendor/swiftmailer/classes/Swift/Plugins/Loggers/ArrayLogger.php b/vendor/swiftmailer/classes/Swift/Plugins/Loggers/ArrayLogger.php
new file mode 100644
index 00000000..f1739e8e
--- /dev/null
+++ b/vendor/swiftmailer/classes/Swift/Plugins/Loggers/ArrayLogger.php
@@ -0,0 +1,72 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Logs to an Array backend.
+ *
+ * @author Chris Corbyn
+ */
+class Swift_Plugins_Loggers_ArrayLogger implements Swift_Plugins_Logger
+{
+ /**
+ * The log contents.
+ *
+ * @var array
+ */
+ private $_log = array();
+
+ /**
+ * Max size of the log.
+ *
+ * @var int
+ */
+ private $_size = 0;
+
+ /**
+ * Create a new ArrayLogger with a maximum of $size entries.
+ *
+ * @var int $size
+ */
+ public function __construct($size = 50)
+ {
+ $this->_size = $size;
+ }
+
+ /**
+ * Add a log entry.
+ *
+ * @param string $entry
+ */
+ public function add($entry)
+ {
+ $this->_log[] = $entry;
+ while (count($this->_log) > $this->_size) {
+ array_shift($this->_log);
+ }
+ }
+
+ /**
+ * Clear the log contents.
+ */
+ public function clear()
+ {
+ $this->_log = array();
+ }
+
+ /**
+ * Get this log as a string.
+ *
+ * @return string
+ */
+ public function dump()
+ {
+ return implode(PHP_EOL, $this->_log);
+ }
+}
diff --git a/vendor/swiftmailer/classes/Swift/Plugins/Loggers/EchoLogger.php b/vendor/swiftmailer/classes/Swift/Plugins/Loggers/EchoLogger.php
new file mode 100644
index 00000000..e8b6c18a
--- /dev/null
+++ b/vendor/swiftmailer/classes/Swift/Plugins/Loggers/EchoLogger.php
@@ -0,0 +1,58 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Prints all log messages in real time.
+ *
+ * @author Chris Corbyn
+ */
+class Swift_Plugins_Loggers_EchoLogger implements Swift_Plugins_Logger
+{
+ /** Whether or not HTML should be output */
+ private $_isHtml;
+
+ /**
+ * Create a new EchoLogger.
+ *
+ * @param bool $isHtml
+ */
+ public function __construct($isHtml = true)
+ {
+ $this->_isHtml = $isHtml;
+ }
+
+ /**
+ * Add a log entry.
+ *
+ * @param string $entry
+ */
+ public function add($entry)
+ {
+ if ($this->_isHtml) {
+ printf('%s%s%s', htmlspecialchars($entry, ENT_QUOTES), '<br />', PHP_EOL);
+ } else {
+ printf('%s%s', $entry, PHP_EOL);
+ }
+ }
+
+ /**
+ * Not implemented.
+ */
+ public function clear()
+ {
+ }
+
+ /**
+ * Not implemented.
+ */
+ public function dump()
+ {
+ }
+}
diff --git a/vendor/swiftmailer/classes/Swift/Plugins/MessageLogger.php b/vendor/swiftmailer/classes/Swift/Plugins/MessageLogger.php
new file mode 100644
index 00000000..a02ad98e
--- /dev/null
+++ b/vendor/swiftmailer/classes/Swift/Plugins/MessageLogger.php
@@ -0,0 +1,75 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2011 Fabien Potencier
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Stores all sent emails for further usage.
+ *
+ * @author Fabien Potencier
+ */
+class Swift_Plugins_MessageLogger implements Swift_Events_SendListener
+{
+ /**
+ * @var array
+ */
+ private $messages;
+
+ public function __construct()
+ {
+ $this->messages = array();
+ }
+
+ /**
+ * Get the message list
+ *
+ * @return array
+ */
+ public function getMessages()
+ {
+ return $this->messages;
+ }
+
+ /**
+ * Get the message count
+ *
+ * @return int count
+ */
+ public function countMessages()
+ {
+ return count($this->messages);
+ }
+
+ /**
+ * Empty the message list
+ *
+ */
+ public function clear()
+ {
+ $this->messages = array();
+ }
+
+ /**
+ * Invoked immediately before the Message is sent.
+ *
+ * @param Swift_Events_SendEvent $evt
+ */
+ public function beforeSendPerformed(Swift_Events_SendEvent $evt)
+ {
+ $this->messages[] = clone $evt->getMessage();
+ }
+
+ /**
+ * Invoked immediately after the Message is sent.
+ *
+ * @param Swift_Events_SendEvent $evt
+ */
+ public function sendPerformed(Swift_Events_SendEvent $evt)
+ {
+ }
+}
diff --git a/vendor/swiftmailer/classes/Swift/Plugins/Pop/Pop3Connection.php b/vendor/swiftmailer/classes/Swift/Plugins/Pop/Pop3Connection.php
new file mode 100644
index 00000000..1e18016a
--- /dev/null
+++ b/vendor/swiftmailer/classes/Swift/Plugins/Pop/Pop3Connection.php
@@ -0,0 +1,31 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Pop3Connection interface for connecting and disconnecting to a POP3 host.
+ *
+ * @author Chris Corbyn
+ */
+interface Swift_Plugins_Pop_Pop3Connection
+{
+ /**
+ * Connect to the POP3 host and throw an Exception if it fails.
+ *
+ * @throws Swift_Plugins_Pop_Pop3Exception
+ */
+ public function connect();
+
+ /**
+ * Disconnect from the POP3 host and throw an Exception if it fails.
+ *
+ * @throws Swift_Plugins_Pop_Pop3Exception
+ */
+ public function disconnect();
+}
diff --git a/vendor/swiftmailer/classes/Swift/Plugins/Pop/Pop3Exception.php b/vendor/swiftmailer/classes/Swift/Plugins/Pop/Pop3Exception.php
new file mode 100644
index 00000000..87020726
--- /dev/null
+++ b/vendor/swiftmailer/classes/Swift/Plugins/Pop/Pop3Exception.php
@@ -0,0 +1,27 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Pop3Exception thrown when an error occurs connecting to a POP3 host.
+ *
+ * @author Chris Corbyn
+ */
+class Swift_Plugins_Pop_Pop3Exception extends Swift_IoException
+{
+ /**
+ * Create a new Pop3Exception with $message.
+ *
+ * @param string $message
+ */
+ public function __construct($message)
+ {
+ parent::__construct($message);
+ }
+}
diff --git a/vendor/swiftmailer/classes/Swift/Plugins/PopBeforeSmtpPlugin.php b/vendor/swiftmailer/classes/Swift/Plugins/PopBeforeSmtpPlugin.php
new file mode 100644
index 00000000..57eea9a7
--- /dev/null
+++ b/vendor/swiftmailer/classes/Swift/Plugins/PopBeforeSmtpPlugin.php
@@ -0,0 +1,274 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Makes sure a connection to a POP3 host has been established prior to connecting to SMTP.
+ *
+ * @author Chris Corbyn
+ */
+class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeListener, Swift_Plugins_Pop_Pop3Connection
+{
+ /** A delegate connection to use (mostly a test hook) */
+ private $_connection;
+
+ /** Hostname of the POP3 server */
+ private $_host;
+
+ /** Port number to connect on */
+ private $_port;
+
+ /** Encryption type to use (if any) */
+ private $_crypto;
+
+ /** Username to use (if any) */
+ private $_username;
+
+ /** Password to use (if any) */
+ private $_password;
+
+ /** Established connection via TCP socket */
+ private $_socket;
+
+ /** Connect timeout in seconds */
+ private $_timeout = 10;
+
+ /** SMTP Transport to bind to */
+ private $_transport;
+
+ /**
+ * Create a new PopBeforeSmtpPlugin for $host and $port.
+ *
+ * @param string $host
+ * @param int $port
+ * @param string $crypto as "tls" or "ssl"
+ */
+ public function __construct($host, $port = 110, $crypto = null)
+ {
+ $this->_host = $host;
+ $this->_port = $port;
+ $this->_crypto = $crypto;
+ }
+
+ /**
+ * Create a new PopBeforeSmtpPlugin for $host and $port.
+ *
+ * @param string $host
+ * @param int $port
+ * @param string $crypto as "tls" or "ssl"
+ *
+ * @return Swift_Plugins_PopBeforeSmtpPlugin
+ */
+ public static function newInstance($host, $port = 110, $crypto = null)
+ {
+ return new self($host, $port, $crypto);
+ }
+
+ /**
+ * Set a Pop3Connection to delegate to instead of connecting directly.
+ *
+ * @param Swift_Plugins_Pop_Pop3Connection $connection
+ *
+ * @return Swift_Plugins_PopBeforeSmtpPlugin
+ */
+ public function setConnection(Swift_Plugins_Pop_Pop3Connection $connection)
+ {
+ $this->_connection = $connection;
+
+ return $this;
+ }
+
+ /**
+ * Bind this plugin to a specific SMTP transport instance.
+ *
+ * @param Swift_Transport
+ */
+ public function bindSmtp(Swift_Transport $smtp)
+ {
+ $this->_transport = $smtp;
+ }
+
+ /**
+ * Set the connection timeout in seconds (default 10).
+ *
+ * @param int $timeout
+ *
+ * @return Swift_Plugins_PopBeforeSmtpPlugin
+ */
+ public function setTimeout($timeout)
+ {
+ $this->_timeout = (int) $timeout;
+
+ return $this;
+ }
+
+ /**
+ * Set the username to use when connecting (if needed).
+ *
+ * @param string $username
+ *
+ * @return Swift_Plugins_PopBeforeSmtpPlugin
+ */
+ public function setUsername($username)
+ {
+ $this->_username = $username;
+
+ return $this;
+ }
+
+ /**
+ * Set the password to use when connecting (if needed).
+ *
+ * @param string $password
+ *
+ * @return Swift_Plugins_PopBeforeSmtpPlugin
+ */
+ public function setPassword($password)
+ {
+ $this->_password = $password;
+
+ return $this;
+ }
+
+ /**
+ * Connect to the POP3 host and authenticate.
+ *
+ * @throws Swift_Plugins_Pop_Pop3Exception if connection fails
+ */
+ public function connect()
+ {
+ if (isset($this->_connection)) {
+ $this->_connection->connect();
+ } else {
+ if (!isset($this->_socket)) {
+ if (!$socket = fsockopen(
+ $this->_getHostString(), $this->_port, $errno, $errstr, $this->_timeout))
+ {
+ throw new Swift_Plugins_Pop_Pop3Exception(
+ sprintf('Failed to connect to POP3 host [%s]: %s', $this->_host, $errstr)
+ );
+ }
+ $this->_socket = $socket;
+
+ if (false === $greeting = fgets($this->_socket)) {
+ throw new Swift_Plugins_Pop_Pop3Exception(
+ sprintf('Failed to connect to POP3 host [%s]', trim($greeting))
+ );
+ }
+
+ $this->_assertOk($greeting);
+
+ if ($this->_username) {
+ $this->_command(sprintf("USER %s\r\n", $this->_username));
+ $this->_command(sprintf("PASS %s\r\n", $this->_password));
+ }
+ }
+ }
+ }
+
+ /**
+ * Disconnect from the POP3 host.
+ */
+ public function disconnect()
+ {
+ if (isset($this->_connection)) {
+ $this->_connection->disconnect();
+ } else {
+ $this->_command("QUIT\r\n");
+ if (!fclose($this->_socket)) {
+ throw new Swift_Plugins_Pop_Pop3Exception(
+ sprintf('POP3 host [%s] connection could not be stopped', $this->_host)
+ );
+ }
+ $this->_socket = null;
+ }
+ }
+
+ /**
+ * Invoked just before a Transport is started.
+ *
+ * @param Swift_Events_TransportChangeEvent $evt
+ */
+ public function beforeTransportStarted(Swift_Events_TransportChangeEvent $evt)
+ {
+ if (isset($this->_transport)) {
+ if ($this->_transport !== $evt->getTransport()) {
+ return;
+ }
+ }
+
+ $this->connect();
+ $this->disconnect();
+ }
+
+ /**
+ * Not used.
+ */
+ public function transportStarted(Swift_Events_TransportChangeEvent $evt)
+ {
+ }
+
+ /**
+ * Not used.
+ */
+ public function beforeTransportStopped(Swift_Events_TransportChangeEvent $evt)
+ {
+ }
+
+ /**
+ * Not used.
+ */
+ public function transportStopped(Swift_Events_TransportChangeEvent $evt)
+ {
+ }
+
+ private function _command($command)
+ {
+ if (!fwrite($this->_socket, $command)) {
+ throw new Swift_Plugins_Pop_Pop3Exception(
+ sprintf('Failed to write command [%s] to POP3 host', trim($command))
+ );
+ }
+
+ if (false === $response = fgets($this->_socket)) {
+ throw new Swift_Plugins_Pop_Pop3Exception(
+ sprintf('Failed to read from POP3 host after command [%s]', trim($command))
+ );
+ }
+
+ $this->_assertOk($response);
+
+ return $response;
+ }
+
+ private function _assertOk($response)
+ {
+ if (substr($response, 0, 3) != '+OK') {
+ throw new Swift_Plugins_Pop_Pop3Exception(
+ sprintf('POP3 command failed [%s]', trim($response))
+ );
+ }
+ }
+
+ private function _getHostString()
+ {
+ $host = $this->_host;
+ switch (strtolower($this->_crypto)) {
+ case 'ssl':
+ $host = 'ssl://' . $host;
+ break;
+
+ case 'tls':
+ $host = 'tls://' . $host;
+ break;
+ }
+
+ return $host;
+ }
+}
diff --git a/vendor/swiftmailer/classes/Swift/Plugins/RedirectingPlugin.php b/vendor/swiftmailer/classes/Swift/Plugins/RedirectingPlugin.php
new file mode 100644
index 00000000..90f380bc
--- /dev/null
+++ b/vendor/swiftmailer/classes/Swift/Plugins/RedirectingPlugin.php
@@ -0,0 +1,205 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2009 Fabien Potencier
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Redirects all email to a single recipient.
+ *
+ * @author Fabien Potencier
+ */
+class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener
+{
+ /**
+ * The recipient who will receive all messages.
+ *
+ * @var mixed
+ */
+ private $_recipient;
+
+ /**
+ * List of regular expression for recipient whitelisting
+ *
+ * @var array
+ */
+ private $_whitelist = array();
+
+ /**
+ * Create a new RedirectingPlugin.
+ *
+ * @param mixed $recipient
+ * @param array $whitelist
+ */
+ public function __construct($recipient, array $whitelist = array())
+ {
+ $this->_recipient = $recipient;
+ $this->_whitelist = $whitelist;
+ }
+
+ /**
+ * Set the recipient of all messages.
+ *
+ * @param mixed $recipient
+ */
+ public function setRecipient($recipient)
+ {
+ $this->_recipient = $recipient;
+ }
+
+ /**
+ * Get the recipient of all messages.
+ *
+ * @return mixed
+ */
+ public function getRecipient()
+ {
+ return $this->_recipient;
+ }
+
+ /**
+ * Set a list of regular expressions to whitelist certain recipients
+ *
+ * @param array $whitelist
+ */
+ public function setWhitelist(array $whitelist)
+ {
+ $this->_whitelist = $whitelist;
+ }
+
+ /**
+ * Get the whitelist
+ *
+ * @return array
+ */
+ public function getWhitelist()
+ {
+ return $this->_whitelist;
+ }
+
+ /**
+ * Invoked immediately before the Message is sent.
+ *
+ * @param Swift_Events_SendEvent $evt
+ */
+ public function beforeSendPerformed(Swift_Events_SendEvent $evt)
+ {
+ $message = $evt->getMessage();
+ $headers = $message->getHeaders();
+
+ // conditionally save current recipients
+
+ if ($headers->has('to')) {
+ $headers->addMailboxHeader('X-Swift-To', $message->getTo());
+ }
+
+ if ($headers->has('cc')) {
+ $headers->addMailboxHeader('X-Swift-Cc', $message->getCc());
+ }
+
+ if ($headers->has('bcc')) {
+ $headers->addMailboxHeader('X-Swift-Bcc', $message->getBcc());
+ }
+
+ // Filter remaining headers against whitelist
+ $this->_filterHeaderSet($headers, 'To');
+ $this->_filterHeaderSet($headers, 'Cc');
+ $this->_filterHeaderSet($headers, 'Bcc');
+
+ // Add each hard coded recipient
+ foreach ( (array) $this->_recipient as $recipient) {
+ if (!array_key_exists($recipient, $message->getTo())) {
+ $message->addTo($recipient);
+ }
+ }
+
+ }
+
+ /**
+ * Filter header set against a whitelist of regular expressions
+ *
+ * @param Swift_Mime_HeaderSet $headerSet
+ * @param string $type
+ */
+ private function _filterHeaderSet(Swift_Mime_HeaderSet $headerSet, $type)
+ {
+ foreach ($headerSet->getAll($type) as $headers) {
+ $headers->setNameAddresses($this->_filterNameAddresses($headers->getNameAddresses()));
+ }
+ }
+
+ /**
+ * Filtered list of addresses => name pairs
+ *
+ * @param array $recipients
+ * @return array
+ */
+ private function _filterNameAddresses(array $recipients)
+ {
+ $filtered = array();
+
+ foreach ($recipients as $address => $name) {
+ if ($this->_isWhitelisted($address)) {
+ $filtered[$address] = $name;
+ }
+ }
+
+ return $filtered;
+ }
+
+ /**
+ * Matches address against whitelist of regular expressions
+ *
+ * @param $recipient
+ * @return bool
+ */
+ protected function _isWhitelisted($recipient)
+ {
+ if (in_array($recipient, (array) $this->_recipient)) {
+ return true;
+ }
+
+ foreach ($this->_whitelist as $pattern) {
+ if (preg_match($pattern, $recipient)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Invoked immediately after the Message is sent.
+ *
+ * @param Swift_Events_SendEvent $evt
+ */
+ public function sendPerformed(Swift_Events_SendEvent $evt)
+ {
+ $this->_restoreMessage($evt->getMessage());
+ }
+
+ private function _restoreMessage(Swift_Mime_Message $message)
+ {
+ // restore original headers
+ $headers = $message->getHeaders();
+
+ if ($headers->has('X-Swift-To')) {
+ $message->setTo($headers->get('X-Swift-To')->getNameAddresses());
+ $headers->removeAll('X-Swift-To');
+ }
+
+ if ($headers->has('X-Swift-Cc')) {
+ $message->setCc($headers->get('X-Swift-Cc')->getNameAddresses());
+ $headers->removeAll('X-Swift-Cc');
+ }
+
+ if ($headers->has('X-Swift-Bcc')) {
+ $message->setBcc($headers->get('X-Swift-Bcc')->getNameAddresses());
+ $headers->removeAll('X-Swift-Bcc');
+ }
+ }
+}
diff --git a/vendor/swiftmailer/classes/Swift/Plugins/Reporter.php b/vendor/swiftmailer/classes/Swift/Plugins/Reporter.php
new file mode 100644
index 00000000..294b547d
--- /dev/null
+++ b/vendor/swiftmailer/classes/Swift/Plugins/Reporter.php
@@ -0,0 +1,32 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * The Reporter plugin sends pass/fail notification to a Reporter.
+ *
+ * @author Chris Corbyn
+ */
+interface Swift_Plugins_Reporter
+{
+ /** The recipient was accepted for delivery */
+ const RESULT_PASS = 0x01;
+
+ /** The recipient could not be accepted */
+ const RESULT_FAIL = 0x10;
+
+ /**
+ * Notifies this ReportNotifier that $address failed or succeeded.
+ *
+ * @param Swift_Mime_Message $message
+ * @param string $address
+ * @param int $result from {@link RESULT_PASS, RESULT_FAIL}
+ */
+ public function notify(Swift_Mime_Message $message, $address, $result);
+}
diff --git a/vendor/swiftmailer/classes/Swift/Plugins/ReporterPlugin.php b/vendor/swiftmailer/classes/Swift/Plugins/ReporterPlugin.php
new file mode 100644
index 00000000..45294533
--- /dev/null
+++ b/vendor/swiftmailer/classes/Swift/Plugins/ReporterPlugin.php
@@ -0,0 +1,73 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Does real time reporting of pass/fail for each recipient.
+ *
+ * @author Chris Corbyn
+ */
+class Swift_Plugins_ReporterPlugin implements Swift_Events_SendListener
+{
+ /**
+ * The reporter backend which takes notifications.
+ *
+ * @var Swift_Plugins_Reporter
+ */
+ private $_reporter;
+
+ /**
+ * Create a new ReporterPlugin using $reporter.
+ *
+ * @param Swift_Plugins_Reporter $reporter
+ */
+ public function __construct(Swift_Plugins_Reporter $reporter)
+ {
+ $this->_reporter = $reporter;
+ }
+
+ /**
+ * Not used.
+ */
+ public function beforeSendPerformed(Swift_Events_SendEvent $evt)
+ {
+ }
+
+ /**
+ * Invoked immediately after the Message is sent.
+ *
+ * @param Swift_Events_SendEvent $evt
+ */
+ public function sendPerformed(Swift_Events_SendEvent $evt)
+ {
+ $message = $evt->getMessage();
+ $failures = array_flip($evt->getFailedRecipients());
+ foreach ((array) $message->getTo() as $address => $null) {
+ $this->_reporter->notify(
+ $message, $address, (array_key_exists($address, $failures)
+ ? Swift_Plugins_Reporter::RESULT_FAIL
+ : Swift_Plugins_Reporter::RESULT_PASS)
+ );
+ }
+ foreach ((array) $message->getCc() as $address => $null) {
+ $this->_reporter->notify(
+ $message, $address, (array_key_exists($address, $failures)
+ ? Swift_Plugins_Reporter::RESULT_FAIL
+ : Swift_Plugins_Reporter::RESULT_PASS)
+ );
+ }
+ foreach ((array) $message->getBcc() as $address => $null) {
+ $this->_reporter->notify(
+ $message, $address, (array_key_exists($address, $failures)
+ ? Swift_Plugins_Reporter::RESULT_FAIL
+ : Swift_Plugins_Reporter::RESULT_PASS)
+ );
+ }
+ }
+}
diff --git a/vendor/swiftmailer/classes/Swift/Plugins/Reporters/HitReporter.php b/vendor/swiftmailer/classes/Swift/Plugins/Reporters/HitReporter.php
new file mode 100644
index 00000000..ea60f51d
--- /dev/null
+++ b/vendor/swiftmailer/classes/Swift/Plugins/Reporters/HitReporter.php
@@ -0,0 +1,59 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * A reporter which "collects" failures for the Reporter plugin.
+ *
+ * @author Chris Corbyn
+ */
+class Swift_Plugins_Reporters_HitReporter implements Swift_Plugins_Reporter
+{
+ /**
+ * The list of failures.
+ *
+ * @var array
+ */
+ private $_failures = array();
+
+ private $_failures_cache = array();
+
+ /**
+ * Notifies this ReportNotifier that $address failed or succeeded.
+ *
+ * @param Swift_Mime_Message $message
+ * @param string $address
+ * @param int $result from {@link RESULT_PASS, RESULT_FAIL}
+ */
+ public function notify(Swift_Mime_Message $message, $address, $result)
+ {
+ if (self::RESULT_FAIL == $result && !isset($this->_failures_cache[$address])) {
+ $this->_failures[] = $address;
+ $this->_failures_cache[$address] = true;
+ }
+ }
+
+ /**
+ * Get an array of addresses for which delivery failed.
+ *
+ * @return array
+ */
+ public function getFailedRecipients()
+ {
+ return $this->_failures;
+ }
+
+ /**
+ * Clear the buffer (empty the list).
+ */
+ public function clear()
+ {
+ $this->_failures = $this->_failures_cache = array();
+ }
+}
diff --git a/vendor/swiftmailer/classes/Swift/Plugins/Reporters/HtmlReporter.php b/vendor/swiftmailer/classes/Swift/Plugins/Reporters/HtmlReporter.php
new file mode 100644
index 00000000..4480d255
--- /dev/null
+++ b/vendor/swiftmailer/classes/Swift/Plugins/Reporters/HtmlReporter.php
@@ -0,0 +1,39 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * A HTML output reporter for the Reporter plugin.
+ *
+ * @author Chris Corbyn
+ */
+class Swift_Plugins_Reporters_HtmlReporter implements Swift_Plugins_Reporter
+{
+ /**
+ * Notifies this ReportNotifier that $address failed or succeeded.
+ *
+ * @param Swift_Mime_Message $message
+ * @param string $address
+ * @param int $result from {@see RESULT_PASS, RESULT_FAIL}
+ */
+ public function notify(Swift_Mime_Message $message, $address, $result)
+ {
+ if (self::RESULT_PASS == $result) {
+ echo "<div style=\"color: #fff; background: #006600; padding: 2px; margin: 2px;\">" . PHP_EOL;
+ echo "PASS " . $address . PHP_EOL;
+ echo "</div>" . PHP_EOL;
+ flush();
+ } else {
+ echo "<div style=\"color: #fff; background: #880000; padding: 2px; margin: 2px;\">" . PHP_EOL;
+ echo "FAIL " . $address . PHP_EOL;
+ echo "</div>" . PHP_EOL;
+ flush();
+ }
+ }
+}
diff --git a/vendor/swiftmailer/classes/Swift/Plugins/Sleeper.php b/vendor/swiftmailer/classes/Swift/Plugins/Sleeper.php
new file mode 100644
index 00000000..38727052
--- /dev/null
+++ b/vendor/swiftmailer/classes/Swift/Plugins/Sleeper.php
@@ -0,0 +1,24 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Sleeps for a duration of time.
+ *
+ * @author Chris Corbyn
+ */
+interface Swift_Plugins_Sleeper
+{
+ /**
+ * Sleep for $seconds.
+ *
+ * @param int $seconds
+ */
+ public function sleep($seconds);
+}
diff --git a/vendor/swiftmailer/classes/Swift/Plugins/ThrottlerPlugin.php b/vendor/swiftmailer/classes/Swift/Plugins/ThrottlerPlugin.php
new file mode 100644
index 00000000..0d2c135e
--- /dev/null
+++ b/vendor/swiftmailer/classes/Swift/Plugins/ThrottlerPlugin.php
@@ -0,0 +1,200 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Throttles the rate at which emails are sent.
+ *
+ * @author Chris Corbyn
+ */
+class Swift_Plugins_ThrottlerPlugin extends Swift_Plugins_BandwidthMonitorPlugin implements Swift_Plugins_Sleeper, Swift_Plugins_Timer
+{
+ /** Flag for throttling in bytes per minute */
+ const BYTES_PER_MINUTE = 0x01;
+
+ /** Flag for throttling in emails per second (Amazon SES) */
+ const MESSAGES_PER_SECOND = 0x11;
+
+ /** Flag for throttling in emails per minute */
+ const MESSAGES_PER_MINUTE = 0x10;
+
+ /**
+ * The Sleeper instance for sleeping.
+ *
+ * @var Swift_Plugins_Sleeper
+ */
+ private $_sleeper;
+
+ /**
+ * The Timer instance which provides the timestamp.
+ *
+ * @var Swift_Plugins_Timer
+ */
+ private $_timer;
+
+ /**
+ * The time at which the first email was sent.
+ *
+ * @var int
+ */
+ private $_start;
+
+ /**
+ * The rate at which messages should be sent.
+ *
+ * @var int
+ */
+ private $_rate;
+
+ /**
+ * The mode for throttling.
+ *
+ * This is {@link BYTES_PER_MINUTE} or {@link MESSAGES_PER_MINUTE}
+ *
+ * @var int
+ */
+ private $_mode;
+
+ /**
+ * An internal counter of the number of messages sent.
+ *
+ * @var int
+ */
+ private $_messages = 0;
+
+ /**
+ * Create a new ThrottlerPlugin.
+ *
+ * @param int $rate
+ * @param int $mode, defaults to {@link BYTES_PER_MINUTE}
+ * @param Swift_Plugins_Sleeper $sleeper (only needed in testing)
+ * @param Swift_Plugins_Timer $timer (only needed in testing)
+ */
+ public function __construct($rate, $mode = self::BYTES_PER_MINUTE, Swift_Plugins_Sleeper $sleeper = null, Swift_Plugins_Timer $timer = null)
+ {
+ $this->_rate = $rate;
+ $this->_mode = $mode;
+ $this->_sleeper = $sleeper;
+ $this->_timer = $timer;
+ }
+
+ /**
+ * Invoked immediately before the Message is sent.
+ *
+ * @param Swift_Events_SendEvent $evt
+ */
+ public function beforeSendPerformed(Swift_Events_SendEvent $evt)
+ {
+ $time = $this->getTimestamp();
+ if (!isset($this->_start)) {
+ $this->_start = $time;
+ }
+ $duration = $time - $this->_start;
+
+ switch ($this->_mode) {
+ case self::BYTES_PER_MINUTE :
+ $sleep = $this->_throttleBytesPerMinute($duration);
+ break;
+ case self::MESSAGES_PER_SECOND :
+ $sleep = $this->_throttleMessagesPerSecond($duration);
+ break;
+ case self::MESSAGES_PER_MINUTE :
+ $sleep = $this->_throttleMessagesPerMinute($duration);
+ break;
+ default :
+ $sleep = 0;
+ break;
+ }
+
+ if ($sleep > 0) {
+ $this->sleep($sleep);
+ }
+ }
+
+ /**
+ * Invoked when a Message is sent.
+ *
+ * @param Swift_Events_SendEvent $evt
+ */
+ public function sendPerformed(Swift_Events_SendEvent $evt)
+ {
+ parent::sendPerformed($evt);
+ ++$this->_messages;
+ }
+
+ /**
+ * Sleep for $seconds.
+ *
+ * @param int $seconds
+ */
+ public function sleep($seconds)
+ {
+ if (isset($this->_sleeper)) {
+ $this->_sleeper->sleep($seconds);
+ } else {
+ sleep($seconds);
+ }
+ }
+
+ /**
+ * Get the current UNIX timestamp.
+ *
+ * @return int
+ */
+ public function getTimestamp()
+ {
+ if (isset($this->_timer)) {
+ return $this->_timer->getTimestamp();
+ } else {
+ return time();
+ }
+ }
+
+ /**
+ * Get a number of seconds to sleep for.
+ *
+ * @param int $timePassed
+ *
+ * @return int
+ */
+ private function _throttleBytesPerMinute($timePassed)
+ {
+ $expectedDuration = $this->getBytesOut() / ($this->_rate / 60);
+
+ return (int) ceil($expectedDuration - $timePassed);
+ }
+
+ /**
+ * Get a number of seconds to sleep for.
+ *
+ * @param int $timePassed
+ *
+ * @return int
+ */
+ private function _throttleMessagesPerSecond($timePassed)
+ {
+ $expectedDuration = $this->_messages / ($this->_rate);
+
+ return (int) ceil($expectedDuration - $timePassed);
+ }
+
+ /**
+ * Get a number of seconds to sleep for.
+ *
+ * @param int $timePassed
+ *
+ * @return int
+ */
+ private function _throttleMessagesPerMinute($timePassed)
+ {
+ $expectedDuration = $this->_messages / ($this->_rate / 60);
+
+ return (int) ceil($expectedDuration - $timePassed);
+ }
+}
diff --git a/vendor/swiftmailer/classes/Swift/Plugins/Timer.php b/vendor/swiftmailer/classes/Swift/Plugins/Timer.php
new file mode 100644
index 00000000..a05e3181
--- /dev/null
+++ b/vendor/swiftmailer/classes/Swift/Plugins/Timer.php
@@ -0,0 +1,24 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Provides timestamp data.
+ *
+ * @author Chris Corbyn
+ */
+interface Swift_Plugins_Timer
+{
+ /**
+ * Get the current UNIX timestamp.
+ *
+ * @return int
+ */
+ public function getTimestamp();
+}