• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • Examples
  • File List

E:/E/GEAMP/www/openbiz/openbiz/others/Zend/Mail/Transport/Smtp.php

00001 <?php
00027 require_once 'Zend/Mime.php';
00028 
00032 require_once 'Zend/Mail/Protocol/Smtp.php';
00033 
00037 require_once 'Zend/Mail/Transport/Abstract.php';
00038 
00039 
00051 class Zend_Mail_Transport_Smtp extends Zend_Mail_Transport_Abstract
00052 {
00058     public $EOL = "\n";
00059 
00065     protected $_host;
00066 
00067 
00073     protected $_port;
00074 
00075 
00081     protected $_name = 'localhost';
00082 
00083 
00089     protected $_auth;
00090 
00091 
00097     protected $_config;
00098 
00099 
00105     protected $_connection;
00106 
00107 
00115     public function __construct($host = '127.0.0.1', Array $config = array())
00116     {
00117         if (isset($config['name'])) {
00118             $this->_name = $config['name'];
00119         }
00120         if (isset($config['port'])) {
00121             $this->_port = $config['port'];
00122         }
00123         if (isset($config['auth'])) {
00124             $this->_auth = $config['auth'];
00125         }
00126 
00127         $this->_host = $host;
00128         $this->_config = $config;
00129     }
00130 
00131 
00137     public function __destruct()
00138     {
00139         if ($this->_connection instanceof Zend_Mail_Protocol_Smtp) {
00140             try {
00141                 $this->_connection->quit();
00142             } catch (Zend_Mail_Protocol_Exception $e) {
00143                 // ignore
00144             }
00145             $this->_connection->disconnect();
00146         }
00147     }
00148 
00149 
00157     public function setConnection(Zend_Mail_Protocol_Abstract $connection)
00158     {
00159         $this->_connection = $connection;
00160     }
00161 
00162 
00168     public function getConnection()
00169     {
00170         return $this->_connection;
00171     }
00172 
00181     public function _sendMail()
00182     {
00183         // If sending multiple messages per session use existing adapter
00184         if (!($this->_connection instanceof Zend_Mail_Protocol_Smtp)) {
00185             // Check if authentication is required and determine required class
00186             $connectionClass = 'Zend_Mail_Protocol_Smtp';
00187             if ($this->_auth) {
00188                 $connectionClass .= '_Auth_' . ucwords($this->_auth);
00189             }
00190             if (!class_exists($connectionClass)) {
00191                 require_once 'Zend/Loader.php';
00192                 Zend_Loader::loadClass($connectionClass);
00193             }
00194             $this->setConnection(new $connectionClass($this->_host, $this->_port, $this->_config));
00195             $this->_connection->connect();
00196             $this->_connection->helo($this->_name);
00197         } else {
00198             // Reset connection to ensure reliable transaction
00199             $this->_connection->rset();
00200         }
00201 
00202         // Set sender email address
00203         $this->_connection->mail($this->_mail->getFrom());
00204 
00205         // Set recipient forward paths
00206         foreach ($this->_mail->getRecipients() as $recipient) {
00207             $this->_connection->rcpt($recipient);
00208         }
00209 
00210         // Issue DATA command to client
00211         $this->_connection->data($this->header . Zend_Mime::LINEEND . $this->body);
00212     }
00213 
00224     protected function _prepareHeaders($headers)
00225     {
00226         if (!$this->_mail) {
00230             require_once 'Zend/Mail/Transport/Exception.php';
00231             throw new Zend_Mail_Transport_Exception('_prepareHeaders requires a registered Zend_Mail object');
00232         }
00233 
00234         unset($headers['Bcc']);
00235 
00236         // Prepare headers
00237         parent::_prepareHeaders($headers);
00238     }
00239 }

Generated on Thu Apr 19 2012 17:01:18 for openbiz by  doxygen 1.7.2