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

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

00001 <?php
00027 require_once 'Zend/Mail/Transport/Abstract.php';
00028 
00029 
00039 class Zend_Mail_Transport_Sendmail extends Zend_Mail_Transport_Abstract
00040 {
00046     public $subject = null;
00047 
00048 
00054     public $parameters;
00055 
00061     public $EOL = PHP_EOL;
00062 
00067     protected $_errstr;
00068 
00075     public function __construct($parameters = null)
00076     {
00077         $this->parameters = $parameters;
00078     }
00079 
00080 
00088     public function _sendMail()
00089     {
00090         set_error_handler(array($this, '_handleMailErrors'));
00091         if ($this->parameters === null) {
00092             $result = mail(
00093                 $this->recipients,
00094                 $this->_mail->getSubject(),
00095                 $this->body,
00096                 $this->header);
00097         } else {
00098             $result = mail(
00099                 $this->recipients,
00100                 $this->_mail->getSubject(),
00101                 $this->body,
00102                 $this->header,
00103                 $this->parameters);
00104         }
00105         restore_error_handler();
00106 
00107         if ($this->_errstr !== null || !$result) {
00111             require_once 'Zend/Mail/Transport/Exception.php';
00112             throw new Zend_Mail_Transport_Exception('Unable to send mail. ' . $this->_errstr);
00113         }
00114     }
00115 
00116 
00129     protected function _prepareHeaders($headers)
00130     {
00131         if (!$this->_mail) {
00135             require_once 'Zend/Mail/Transport/Exception.php';
00136             throw new Zend_Mail_Transport_Exception('_prepareHeaders requires a registered Zend_Mail object');
00137         }
00138 
00139         // mail() uses its $to parameter to set the To: header, and the $subject
00140         // parameter to set the Subject: header. We need to strip them out.
00141         if (0 === strpos(PHP_OS, 'WIN')) {
00142             // If the current recipients list is empty, throw an error
00143             if (empty($this->recipients)) {
00147                 require_once 'Zend/Mail/Transport/Exception.php';
00148                 throw new Zend_Mail_Transport_Exception('Missing To addresses');
00149             }
00150         } else {
00151             // All others, simply grab the recipients and unset the To: header
00152             if (!isset($headers['To'])) {
00156                 require_once 'Zend/Mail/Transport/Exception.php';
00157                 throw new Zend_Mail_Transport_Exception('Missing To header');
00158             }
00159 
00160             unset($headers['To']['append']);
00161             $this->recipients = implode(',', $headers['To']);
00162         }
00163 
00164         // Remove recipient header
00165         unset($headers['To']);
00166 
00167         // Remove subject header, if present
00168         if (isset($headers['Subject'])) {
00169             unset($headers['Subject']);
00170         }
00171 
00172         // Prepare headers
00173         parent::_prepareHeaders($headers);
00174 
00175         // Fix issue with empty blank line ontop when using Sendmail Trnasport
00176         $this->header = rtrim($this->header);
00177     }
00178 
00189     public function _handleMailErrors($errno, $errstr, $errfile = null, $errline = null, array $errcontext = null)
00190     {
00191         $this->_errstr = $errstr;
00192         return true;
00193     }
00194 
00195 }

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