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:  * SendmailTransport for sending mail through a sendmail/postfix (etc..) binary.
 13:  *
 14:  * Supported modes are -bs and -t, with any additional flags desired.
 15:  * It is advised to use -bs mode since error reporting with -t mode is not
 16:  * possible.
 17:  *
 18:  * @package Swift
 19:  * @subpackage Transport
 20:  * @author Chris Corbyn
 21:  */
 22: class Swift_Transport_SendmailTransport extends Swift_Transport_AbstractSmtpTransport
 23: {
 24:     /**
 25:      * Connection buffer parameters.
 26:      * @var array
 27:      * @access protected
 28:      */
 29:     private $_params = array(
 30:         'timeout' => 30,
 31:         'blocking' => 1,
 32:         'command' => '/usr/sbin/sendmail -bs',
 33:         'type' => Swift_Transport_IoBuffer::TYPE_PROCESS
 34:         );
 35: 
 36:     /**
 37:      * Create a new SendmailTransport with $buf for I/O.
 38:      * @param Swift_Transport_IoBuffer     $buf
 39:      * @param Swift_Events_EventDispatcher $dispatcher
 40:      */
 41:     public function __construct(Swift_Transport_IoBuffer $buf, Swift_Events_EventDispatcher $dispatcher)
 42:     {
 43:         parent::__construct($buf, $dispatcher);
 44:     }
 45: 
 46:     /**
 47:      * Start the standalone SMTP session if running in -bs mode.
 48:      */
 49:     public function start()
 50:     {
 51:         if (false !== strpos($this->getCommand(), ' -bs')) {
 52:             parent::start();
 53:         }
 54:     }
 55: 
 56:     /**
 57:      * Set the command to invoke.
 58:      * If using -t mode you are strongly advised to include -oi or -i in the
 59:      * flags. For example: /usr/sbin/sendmail -oi -t
 60:      * Swift will append a -f<sender> flag if one is not present.
 61:      * The recommended mode is "-bs" since it is interactive and failure notifications
 62:      * are hence possible.
 63:      * @param  string                            $command
 64:      * @return Swift_Transport_SendmailTransport
 65:      */
 66:     public function setCommand($command)
 67:     {
 68:         $this->_params['command'] = $command;
 69: 
 70:         return $this;
 71:     }
 72: 
 73:     /**
 74:      * Get the sendmail command which will be invoked.
 75:      * @return string
 76:      */
 77:     public function getCommand()
 78:     {
 79:         return $this->_params['command'];
 80:     }
 81: 
 82:     /**
 83:      * Send the given Message.
 84:      * Recipient/sender data will be retrieved from the Message API.
 85:      * The return value is the number of recipients who were accepted for delivery.
 86:      * NOTE: If using 'sendmail -t' you will not be aware of any failures until
 87:      * they bounce (i.e. send() will always return 100% success).
 88:      * @param Swift_Mime_Message $message
 89:      * @param string[] &$failedRecipients to collect failures by-reference
 90:      * @return int
 91:      */
 92:     public function send(Swift_Mime_Message $message, &$failedRecipients = null)
 93:     {
 94:         $failedRecipients = (array) $failedRecipients;
 95:         $command = $this->getCommand();
 96:         $buffer = $this->getBuffer();
 97: 
 98:         if (false !== strpos($command, ' -t')) {
 99:             if ($evt = $this->_eventDispatcher->createSendEvent($this, $message)) {
100:                 $this->_eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed');
101:                 if ($evt->bubbleCancelled()) {
102:                     return 0;
103:                 }
104:             }
105: 
106:             if (false === strpos($command, ' -f')) {
107:                 $command .= ' -f' . $this->_getReversePath($message);
108:             }
109: 
110:             $buffer->initialize(array_merge($this->_params, array('command' => $command)));
111: 
112:             if (false === strpos($command, ' -i') && false === strpos($command, ' -oi')) {
113:                 $buffer->setWriteTranslations(array("\r\n" => "\n", "\n." => "\n.."));
114:             } else {
115:                 $buffer->setWriteTranslations(array("\r\n"=>"\n"));
116:             }
117: 
118:             $count = count((array) $message->getTo())
119:                 + count((array) $message->getCc())
120:                 + count((array) $message->getBcc())
121:                 ;
122:             $message->toByteStream($buffer);
123:             $buffer->flushBuffers();
124:             $buffer->setWriteTranslations(array());
125:             $buffer->terminate();
126: 
127:             if ($evt) {
128:                 $evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS);
129:                 $evt->setFailedRecipients($failedRecipients);
130:                 $this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed');
131:             }
132: 
133:             $message->generateId();
134:         } elseif (false !== strpos($command, ' -bs')) {
135:             $count = parent::send($message, $failedRecipients);
136:         } else {
137:             $this->_throwException(new Swift_TransportException(
138:                 'Unsupported sendmail command flags [' . $command . ']. ' .
139:                 'Must be one of "-bs" or "-t" but can include additional flags.'
140:                 ));
141:         }
142: 
143:         return $count;
144:     }
145: 
146:     // -- Protected methods
147: 
148:     /** Get the params to initialize the buffer */
149:     protected function _getBufferParams()
150:     {
151:         return $this->_params;
152:     }
153: }
154: 
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen