Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Swift_FailoverTransport
  • Swift_LoadBalancedTransport
  • Swift_MailTransport
  • Swift_Plugins_Loggers_ArrayLogger
  • Swift_Plugins_Loggers_EchoLogger
  • Swift_SendmailTransport
  • Swift_SmtpTransport
  • Swift_Transport_AbstractSmtpTransport
  • Swift_Transport_Esmtp_Auth_CramMd5Authenticator
  • Swift_Transport_Esmtp_Auth_LoginAuthenticator
  • Swift_Transport_Esmtp_Auth_PlainAuthenticator
  • Swift_Transport_Esmtp_AuthHandler
  • Swift_Transport_EsmtpTransport
  • Swift_Transport_FailoverTransport
  • Swift_Transport_LoadBalancedTransport
  • Swift_Transport_MailTransport
  • Swift_Transport_SendmailTransport
  • Swift_Transport_SimpleMailInvoker
  • Swift_Transport_StreamBuffer

Interfaces

  • Swift_Plugins_Logger
  • Swift_Plugins_Pop_Pop3Exception
  • Swift_Transport
  • Swift_Transport_Esmtp_Authenticator
  • Swift_Transport_EsmtpHandler
  • Swift_Transport_IoBuffer
  • Swift_Transport_MailInvoker
  • Swift_Transport_SmtpAgent
  • Swift_TransportException
  • Overview
  • Package
  • Function
  • Todo
  • Download
 1: <?php
 2: 
 3: /*
 4:  * This file is part of SwiftMailer.
 5:  * (c) 2004-2009 Chris Corbyn
 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:  * Contains a list of redundant Transports so when one fails, the next is used.
13:  * @package Swift
14:  * @subpackage Transport
15:  * @author Chris Corbyn
16:  */
17: class Swift_Transport_FailoverTransport extends Swift_Transport_LoadBalancedTransport
18: {
19:     /**
20:      * Registered transport curently used.
21:      * @var Swift_Transport
22:      * @access private
23:      */
24:     private $_currentTransport;
25: 
26:     /**
27:      * Creates a new FailoverTransport.
28:      */
29:     public function __construct()
30:     {
31:         parent::__construct();
32:     }
33: 
34:     /**
35:      * Send the given Message.
36:      * Recipient/sender data will be retrieved from the Message API.
37:      * The return value is the number of recipients who were accepted for delivery.
38:      * @param Swift_Mime_Message $message
39:      * @param string[] &$failedRecipients to collect failures by-reference
40:      * @return int
41:      */
42:     public function send(Swift_Mime_Message $message, &$failedRecipients = null)
43:     {
44:         $maxTransports = count($this->_transports);
45:         $sent = 0;
46: 
47:         for ($i = 0; $i < $maxTransports
48:             && $transport = $this->_getNextTransport(); ++$i)
49:         {
50:             try {
51:                 if (!$transport->isStarted()) {
52:                     $transport->start();
53:                 }
54: 
55:                 return $transport->send($message, $failedRecipients);
56:             } catch (Swift_TransportException $e) {
57:                 $this->_killCurrentTransport();
58:             }
59:         }
60: 
61:         if (count($this->_transports) == 0) {
62:             throw new Swift_TransportException(
63:                 'All Transports in FailoverTransport failed, or no Transports available'
64:                 );
65:         }
66: 
67:         return $sent;
68:     }
69: 
70:     // -- Protected methods
71: 
72:     protected function _getNextTransport()
73:     {
74:         if (!isset($this->_currentTransport)) {
75:             $this->_currentTransport = parent::_getNextTransport();
76:         }
77: 
78:         return $this->_currentTransport;
79:     }
80: 
81:     protected function _killCurrentTransport()
82:     {
83:         $this->_currentTransport = null;
84:         parent::_killCurrentTransport();
85:     }
86: }
87: 
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen