From 07f5140771388c9e0c8a99b0dd2e5d950bdb173b Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Thu, 14 Oct 2021 15:16:42 +1100 Subject: moving h-source subdir out. --- .../classes/Swift/Transport/FailoverTransport.php | 97 ++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100755 External/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php (limited to 'External/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php') diff --git a/External/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php b/External/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php new file mode 100755 index 0000000..e62491c --- /dev/null +++ b/External/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php @@ -0,0 +1,97 @@ +_transports); + $sent = 0; + + for ($i = 0; $i < $maxTransports + && $transport = $this->_getNextTransport(); ++$i) + { + try + { + if (!$transport->isStarted()) + { + $transport->start(); + } + + return $transport->send($message, $failedRecipients); + } + catch (Swift_TransportException $e) + { + $this->_killCurrentTransport(); + } + } + + if (count($this->_transports) == 0) + { + throw new Swift_TransportException( + 'All Transports in FailoverTransport failed, or no Transports available' + ); + } + + return $sent; + } + + // -- Protected methods + + protected function _getNextTransport() + { + if (!isset($this->_currentTransport)) + { + $this->_currentTransport = parent::_getNextTransport(); + } + return $this->_currentTransport; + } + + protected function _killCurrentTransport() + { + $this->_currentTransport = null; + parent::_killCurrentTransport(); + } + +} -- cgit v1.2.3