File indexing completed on 2024-12-22 05:36:51
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Mail 0017 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0018 * @license http://framework.zend.com/license/new-bsd New BSD License 0019 * @version $Id$ 0020 */ 0021 0022 0023 /** 0024 * Zend_Mail_Part 0025 */ 0026 // require_once 'Zend/Mail/Part.php'; 0027 0028 /** 0029 * Zend_Mail_Message_Interface 0030 */ 0031 // require_once 'Zend/Mail/Message/Interface.php'; 0032 0033 /** 0034 * @category Zend 0035 * @package Zend_Mail 0036 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0037 * @license http://framework.zend.com/license/new-bsd New BSD License 0038 */ 0039 class Zend_Mail_Message extends Zend_Mail_Part implements Zend_Mail_Message_Interface 0040 { 0041 /** 0042 * flags for this message 0043 * @var array 0044 */ 0045 protected $_flags = array(); 0046 0047 /** 0048 * Public constructor 0049 * 0050 * In addition to the parameters of Zend_Mail_Part::__construct() this constructor supports: 0051 * - file filename or file handle of a file with raw message content 0052 * - flags array with flags for message, keys are ignored, use constants defined in Zend_Mail_Storage 0053 * 0054 * @param string $rawMessage full message with or without headers 0055 * @throws Zend_Mail_Exception 0056 */ 0057 public function __construct(array $params) 0058 { 0059 if (isset($params['file'])) { 0060 if (!is_resource($params['file'])) { 0061 $params['raw'] = @file_get_contents($params['file']); 0062 if ($params['raw'] === false) { 0063 /** 0064 * @see Zend_Mail_Exception 0065 */ 0066 // require_once 'Zend/Mail/Exception.php'; 0067 throw new Zend_Mail_Exception('could not open file'); 0068 } 0069 } else { 0070 $params['raw'] = stream_get_contents($params['file']); 0071 } 0072 $params['raw'] = preg_replace("/(?<!\r)\n/", "\r\n", $params['raw']); 0073 } 0074 0075 if (!empty($params['flags'])) { 0076 // set key and value to the same value for easy lookup 0077 $this->_flags = array_merge($this->_flags, array_combine($params['flags'],$params['flags'])); 0078 } 0079 0080 parent::__construct($params); 0081 } 0082 0083 /** 0084 * return toplines as found after headers 0085 * 0086 * @return string toplines 0087 */ 0088 public function getTopLines() 0089 { 0090 return $this->_topLines; 0091 } 0092 0093 /** 0094 * check if flag is set 0095 * 0096 * @param mixed $flag a flag name, use constants defined in Zend_Mail_Storage 0097 * @return bool true if set, otherwise false 0098 */ 0099 public function hasFlag($flag) 0100 { 0101 return isset($this->_flags[$flag]); 0102 } 0103 0104 /** 0105 * get all set flags 0106 * 0107 * @return array array with flags, key and value are the same for easy lookup 0108 */ 0109 public function getFlags() 0110 { 0111 return $this->_flags; 0112 } 0113 }