Changeset 19942 for branches/version-2_5-dev/data/module/Mail/mail.php
- Timestamp:
- 2011/01/17 14:46:37 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_5-dev/data/module/Mail/mail.php
r16503 r19942 1 1 <?php 2 // 3 // +----------------------------------------------------------------------+ 4 // | PHP Version 4 | 5 // +----------------------------------------------------------------------+ 6 // | Copyright (c) 1997-2003 The PHP Group | 7 // +----------------------------------------------------------------------+ 8 // | This source file is subject to version 2.02 of the PHP license, | 9 // | that is bundled with this package in the file LICENSE, and is | 10 // | available at through the world-wide-web at | 11 // | http://www.php.net/license/2_02.txt. | 12 // | If you did not receive a copy of the PHP license and are unable to | 13 // | obtain it through the world-wide-web, please send a note to | 14 // | license@php.net so we can mail you a copy immediately. | 15 // +----------------------------------------------------------------------+ 16 // | Author: Chuck Hagenbuch <chuck@horde.org> | 17 // +----------------------------------------------------------------------+ 18 // 19 // $Id$ 2 /** 3 * internal PHP-mail() implementation of the PEAR Mail:: interface. 4 * 5 * PHP versions 4 and 5 6 * 7 * LICENSE: 8 * 9 * Copyright (c) 2010 Chuck Hagenbuch 10 * All rights reserved. 11 * 12 * Redistribution and use in source and binary forms, with or without 13 * modification, are permitted provided that the following conditions 14 * are met: 15 * 16 * o Redistributions of source code must retain the above copyright 17 * notice, this list of conditions and the following disclaimer. 18 * o Redistributions in binary form must reproduce the above copyright 19 * notice, this list of conditions and the following disclaimer in the 20 * documentation and/or other materials provided with the distribution. 21 * o The names of the authors may not be used to endorse or promote 22 * products derived from this software without specific prior written 23 * permission. 24 * 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 29 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 31 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 * 37 * @category Mail 38 * @package Mail 39 * @author Chuck Hagenbuch <chuck@horde.org> 40 * @copyright 2010 Chuck Hagenbuch 41 * @license http://opensource.org/licenses/bsd-license.php New BSD License 42 * @version CVS: $Id$ 43 * @link http://pear.php.net/package/Mail/ 44 */ 20 45 21 46 /** … … 42 67 function Mail_mail($params = null) 43 68 { 44 / *The other mail implementations accept parameters as arrays.45 *In the interest of being consistent, explode an array into46 * a string of parameter arguments. */69 // The other mail implementations accept parameters as arrays. 70 // In the interest of being consistent, explode an array into 71 // a string of parameter arguments. 47 72 if (is_array($params)) { 48 73 $this->_params = join(' ', $params); … … 62 87 } 63 88 64 89 /** 65 90 * Implements Mail_mail::send() function using php's built-in mail() 66 91 * command. … … 90 115 function send($recipients, $headers, $body) 91 116 { 92 $this->_sanitizeHeaders($headers); 117 if (!is_array($headers)) { 118 return PEAR::raiseError('$headers must be an array'); 119 } 120 121 $result = $this->_sanitizeHeaders($headers); 122 if (is_a($result, 'PEAR_Error')) { 123 return $result; 124 } 93 125 94 126 // If we're passed an array of recipients, implode it. … … 105 137 } 106 138 107 /* 108 * Also remove the To: header. The mail() function will add its own 109 * To: header based on the contents of $recipients. 110 */ 139 // Also remove the To: header. The mail() function will add its own 140 // To: header based on the contents of $recipients. 111 141 unset($headers['To']); 112 142 113 143 // Flatten the headers out. 114 144 $headerElements = $this->prepareHeaders($headers); 115 if ( PEAR::isError($headerElements)) {145 if (is_a($headerElements, 'PEAR_Error')) { 116 146 return $headerElements; 117 147 } 118 148 list(, $text_headers) = $headerElements; 119 149 120 /* 121 * We only use mail()'s optional fifth parameter if the additional 122 * parameters have been provided and we're not running in safe mode. 123 */ 150 // We only use mail()'s optional fifth parameter if the additional 151 // parameters have been provided and we're not running in safe mode. 124 152 if (empty($this->_params) || ini_get('safe_mode')) { 125 153 $result = mail($recipients, $subject, $body, $text_headers); … … 129 157 } 130 158 131 /* 132 * If the mail() function returned failure, we need to create a 133 * PEAR_Error object and return it instead of the boolean result. 134 */ 159 // If the mail() function returned failure, we need to create a 160 // PEAR_Error object and return it instead of the boolean result. 135 161 if ($result === false) { 136 162 $result = PEAR::raiseError('mail() returned failure');
Note: See TracChangeset
for help on using the changeset viewer.