Fixed issue #705

Change-Id: I602a88d24c2a482e6bebb5d6d7f4830843afec42
Signed-off-by: SJ <sj@acts.hu>
This commit is contained in:
SJ 2016-09-10 22:16:35 +02:00
parent 802c811a70
commit db1a202c5c
42 changed files with 1074 additions and 342 deletions

View File

@ -14,15 +14,15 @@
*
* @category Zend
* @package Zend
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Exception.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
/**
* @category Zend
* @package Zend
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Exception extends Exception

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Mail
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Mail.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
@ -46,7 +46,7 @@ require_once 'Zend/Mime/Part.php';
*
* @category Zend
* @package Zend_Mail
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Mail extends Zend_Mime_Message
@ -209,7 +209,6 @@ class Zend_Mail extends Zend_Mime_Message
* Public constructor
*
* @param string $charset
* @return void
*/
public function __construct($charset = null)
{
@ -329,8 +328,10 @@ class Zend_Mail extends Zend_Mime_Message
/**
* Set the encoding of mail headers
*
* @param string $encoding Zend_Mime::ENCODING_QUOTEDPRINTABLE or Zend_Mime::ENCODING_BASE64
* @param string $encoding Zend_Mime::ENCODING_QUOTEDPRINTABLE or
* Zend_Mime::ENCODING_BASE64
* @return Zend_Mail Provides fluent interface
* @throws Zend_Mail_Exception
*/
public function setHeaderEncoding($encoding)
{
@ -378,7 +379,8 @@ class Zend_Mail extends Zend_Mime_Message
/**
* Return text body Zend_Mime_Part or string
*
* @param bool textOnly Whether to return just the body text content or the MIME part; defaults to false, the MIME part
* @param bool $textOnly Whether to return just the body text content or
* the MIME part; defaults to false, the MIME part
* @return false|Zend_Mime_Part|string
*/
public function getBodyText($textOnly = false)
@ -562,7 +564,8 @@ class Zend_Mail extends Zend_Mime_Message
}
/**
* Adds To-header and recipient, $email can be an array, or a single string address
* Adds To-header and recipient, $email can be an array, or a single string
* address
*
* @param string|array $email
* @param string $name
@ -583,7 +586,8 @@ class Zend_Mail extends Zend_Mime_Message
}
/**
* Adds Cc-header and recipient, $email can be an array, or a single string address
* Adds Cc-header and recipient, $email can be an array, or a single string
* address
*
* @param string|array $email
* @param string $name
@ -764,7 +768,7 @@ class Zend_Mail extends Zend_Mime_Message
* Sets Default From-email and name of the message
*
* @param string $email
* @param string Optional $name
* @param string $name optional
* @return void
*/
public static function setDefaultFrom($email, $name = null)
@ -796,6 +800,7 @@ class Zend_Mail extends Zend_Mime_Message
* Sets From-name and -email based on the defaults
*
* @return Zend_Mail Provides fluent interface
* @throws Zend_Mail_Exception
*/
public function setFromToDefaultFrom() {
$from = self::getDefaultFrom();
@ -814,7 +819,7 @@ class Zend_Mail extends Zend_Mime_Message
* Sets Default ReplyTo-address and -name of the message
*
* @param string $email
* @param string Optional $name
* @param string $name optional
* @return void
*/
public static function setDefaultReplyTo($email, $name = null)
@ -846,6 +851,7 @@ class Zend_Mail extends Zend_Mime_Message
* Sets ReplyTo-name and -email based on the defaults
*
* @return Zend_Mail Provides fluent interface
* @throws Zend_Mail_Exception
*/
public function setReplyToFromDefault() {
$replyTo = self::getDefaultReplyTo();
@ -961,9 +967,10 @@ class Zend_Mail extends Zend_Mime_Message
/**
* Sets Date-header
*
* @param timestamp|string|Zend_Date $date
* @param int|string|Zend_Date $date
* @return Zend_Mail Provides fluent interface
* @throws Zend_Mail_Exception if called subsequent times or wrong date format.
* @throws Zend_Mail_Exception if called subsequent times or wrong date
* format.
*/
public function setDate($date = null)
{
@ -1153,7 +1160,7 @@ class Zend_Mail extends Zend_Mime_Message
/**
* Return mail headers
*
* @return void
* @return array
*/
public function getHeaders()
{
@ -1264,7 +1271,7 @@ class Zend_Mail extends Zend_Mime_Message
return $email;
} else {
$encodedName = $this->_encodeHeader($name);
if ($encodedName === $name && strcspn($name, '()<>[]:;@\\,') != strlen($name)) {
if ($encodedName === $name && strcspn($name, '()<>[]:;@\\,.') != strlen($name)) {
$format = '"%s" <%s>';
} else {
$format = '%s <%s>';

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Mail
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Exception.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
@ -29,7 +29,7 @@ require_once 'Zend/Exception.php';
/**
* @category Zend
* @package Zend_Mail
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Mail_Exception extends Zend_Exception

View File

@ -0,0 +1,92 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Mail
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @category Zend
* @package Zend_Mail
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
final class Zend_Mail_Header_HeaderName
{
/**
* No public constructor.
*/
private function __construct()
{
}
/**
* Filter the header name according to RFC 2822
*
* @see http://www.rfc-base.org/txt/rfc-2822.txt (section 2.2)
* @param string $name
* @return string
*/
public static function filter($name)
{
$result = '';
$tot = strlen($name);
for ($i = 0; $i < $tot; $i += 1) {
$ord = ord($name[$i]);
if ($ord > 32 && $ord < 127 && $ord !== 58) {
$result .= $name[$i];
}
}
return $result;
}
/**
* Determine if the header name contains any invalid characters.
*
* @param string $name
* @return bool
*/
public static function isValid($name)
{
$tot = strlen($name);
for ($i = 0; $i < $tot; $i += 1) {
$ord = ord($name[$i]);
if ($ord < 33 || $ord > 126 || $ord === 58) {
return false;
}
}
return true;
}
/**
* Assert that the header name is valid.
*
* Raises an exception if invalid.
*
* @param string $name
* @throws Exception\RuntimeException
* @return void
*/
public static function assertValid($name)
{
if (! self::isValid($name)) {
require_once 'Zend/Mail/Exception.php';
throw new Zend_Mail_Exception('Invalid header name detected');
}
}
}

View File

@ -0,0 +1,136 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Mail
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @category Zend
* @package Zend_Mail
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
final class Zend_Mail_Header_HeaderValue
{
/**
* No public constructor.
*/
private function __construct()
{
}
/**
* Filter the header value according to RFC 2822
*
* @see http://www.rfc-base.org/txt/rfc-2822.txt (section 2.2)
* @param string $value
* @return string
*/
public static function filter($value)
{
$result = '';
$tot = strlen($value);
// Filter for CR and LF characters, leaving CRLF + WSP sequences for
// Long Header Fields (section 2.2.3 of RFC 2822)
for ($i = 0; $i < $tot; $i += 1) {
$ord = ord($value[$i]);
if (($ord < 32 || $ord > 126)
&& $ord !== 13
) {
continue;
}
if ($ord === 13) {
if ($i + 2 >= $tot) {
continue;
}
$lf = ord($value[$i + 1]);
$sp = ord($value[$i + 2]);
if ($lf !== 10 || $sp !== 32) {
continue;
}
$result .= "\r\n ";
$i += 2;
continue;
}
$result .= $value[$i];
}
return $result;
}
/**
* Determine if the header value contains any invalid characters.
*
* @see http://www.rfc-base.org/txt/rfc-2822.txt (section 2.2)
* @param string $value
* @return bool
*/
public static function isValid($value)
{
$tot = strlen($value);
for ($i = 0; $i < $tot; $i += 1) {
$ord = ord($value[$i]);
if (($ord < 32 || $ord > 126)
&& $ord !== 13
) {
return false;
}
if ($ord === 13) {
if ($i + 2 >= $tot) {
return false;
}
$lf = ord($value[$i + 1]);
$sp = ord($value[$i + 2]);
if ($lf !== 10 || $sp !== 32) {
return false;
}
$i += 2;
}
}
return true;
}
/**
* Assert that the header value is valid.
*
* Raises an exception if invalid.
*
* @param string $value
* @throws Exception\RuntimeException
* @return void
*/
public static function assertValid($value)
{
if (! self::isValid($value)) {
require_once 'Zend/Mail/Exception.php';
throw new Zend_Mail_Exception('Invalid header value detected');
}
}
}

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Mail
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Message.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
@ -33,7 +33,7 @@ require_once 'Zend/Mail/Message/Interface.php';
/**
* @category Zend
* @package Zend_Mail
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Mail_Message extends Zend_Mail_Part implements Zend_Mail_Message_Interface
@ -69,6 +69,7 @@ class Zend_Mail_Message extends Zend_Mail_Part implements Zend_Mail_Message_Inte
} else {
$params['raw'] = stream_get_contents($params['file']);
}
$params['raw'] = preg_replace("/(?<!\r)\n/", "\r\n", $params['raw']);
}
if (!empty($params['flags'])) {

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Mail
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: File.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
@ -33,7 +33,7 @@ require_once 'Zend/Mail/Message/Interface.php';
/**
* @category Zend
* @package Zend_Mail
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Mail_Message_File extends Zend_Mail_Part_File implements Zend_Mail_Message_Interface

View File

@ -15,9 +15,9 @@
* @category Zend
* @package Zend_Mail
* @subpackage Storage
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Interface.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
@ -25,7 +25,7 @@
* @category Zend
* @package Zend_Mail
* @subpackage Storage
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Mail
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Part.php 24759 2012-05-05 02:58:55Z adamlundrigan $
* @version $Id$
*/
@ -25,6 +25,16 @@
*/
require_once 'Zend/Mime/Decode.php';
/**
* @see Zend_Mail_Header_HeaderName
*/
require_once 'Zend/Mail/Header/HeaderName.php';
/**
* @see Zend_Mail_Header_HeaderValue
*/
require_once 'Zend/Mail/Header/HeaderValue.php';
/**
* @see Zend_Mail_Part_Interface
*/
@ -34,7 +44,7 @@ require_once 'Zend/Mail/Part/Interface.php';
/**
* @category Zend
* @package Zend_Mail
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Mail_Part implements RecursiveIterator, Zend_Mail_Part_Interface
@ -134,17 +144,19 @@ class Zend_Mail_Part implements RecursiveIterator, Zend_Mail_Part_Interface
}
if (isset($params['raw'])) {
Zend_Mime_Decode::splitMessage($params['raw'], $this->_headers, $this->_content);
Zend_Mime_Decode::splitMessage($params['raw'], $this->_headers, $this->_content, "\r\n");
} else if (isset($params['headers'])) {
if (is_array($params['headers'])) {
$this->_headers = $params['headers'];
$this->_validateHeaders($this->_headers);
} else {
if (!empty($params['noToplines'])) {
Zend_Mime_Decode::splitMessage($params['headers'], $this->_headers, $null);
Zend_Mime_Decode::splitMessage($params['headers'], $this->_headers, $null, "\r\n");
} else {
Zend_Mime_Decode::splitMessage($params['headers'], $this->_headers, $this->_topLines);
Zend_Mime_Decode::splitMessage($params['headers'], $this->_headers, $this->_topLines, "\r\n");
}
}
if (isset($params['content'])) {
$this->_content = $params['content'];
}
@ -566,4 +578,26 @@ class Zend_Mail_Part implements RecursiveIterator, Zend_Mail_Part_Interface
$this->countParts();
$this->_iterationPos = 1;
}
/**
* Ensure headers do not contain invalid characters
*
* @param array $headers
* @param bool $assertNames
*/
protected function _validateHeaders(array $headers, $assertNames = true)
{
foreach ($headers as $name => $value) {
if ($assertNames) {
Zend_Mail_Header_HeaderName::assertValid($name);
}
if (is_array($value)) {
$this->_validateHeaders($value, false);
continue;
}
Zend_Mail_Header_HeaderValue::assertValid($value);
}
}
}

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Mail
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: File.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
@ -34,7 +34,7 @@ require_once 'Zend/Mail/Part.php';
/**
* @category Zend
* @package Zend_Mail
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Mail_Part_File extends Zend_Mail_Part

View File

@ -15,9 +15,9 @@
* @category Zend
* @package Zend_Mail
* @subpackage Storage
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Interface.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
@ -25,7 +25,7 @@
* @category Zend
* @package Zend_Mail
* @subpackage Storage
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

View File

@ -16,9 +16,9 @@
* @category Zend
* @package Zend_Mail
* @subpackage Protocol
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Abstract.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
@ -42,9 +42,9 @@ require_once 'Zend/Validate/Hostname.php';
* @category Zend
* @package Zend_Mail
* @subpackage Protocol
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Abstract.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
* @todo Implement proxy settings
*/
abstract class Zend_Mail_Protocol_Abstract

View File

@ -15,9 +15,9 @@
* @category Zend
* @package Zend_Mail
* @subpackage Protocol
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Exception.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
@ -31,7 +31,7 @@ require_once 'Zend/Mail/Exception.php';
* @category Zend
* @package Zend_Mail
* @subpackage Protocol
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Mail_Protocol_Exception extends Zend_Mail_Exception

View File

@ -15,9 +15,9 @@
* @category Zend
* @package Zend_Mail
* @subpackage Protocol
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Imap.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
@ -25,7 +25,7 @@
* @category Zend
* @package Zend_Mail
* @subpackage Protocol
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Mail_Protocol_Imap
@ -91,7 +91,17 @@ class Zend_Mail_Protocol_Imap
$errno = 0;
$errstr = '';
$this->_socket = @fsockopen($host, $port, $errno, $errstr, self::TIMEOUT_CONNECTION);
$contextOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false
)
);
$context = stream_context_create($contextOptions);
$this->_socket = stream_socket_client("{$host}:{$port}", $errno, $errstr, 20, STREAM_CLIENT_CONNECT, $context);
if (!$this->_socket) {
/**
* @see Zend_Mail_Protocol_Exception

View File

@ -15,9 +15,9 @@
* @category Zend
* @package Zend_Mail
* @subpackage Protocol
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Pop3.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
@ -25,7 +25,7 @@
* @category Zend
* @package Zend_Mail
* @subpackage Protocol
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Mail_Protocol_Pop3

View File

@ -16,9 +16,9 @@
* @category Zend
* @package Zend_Mail
* @subpackage Protocol
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Smtp.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
@ -42,7 +42,7 @@ require_once 'Zend/Mail/Protocol/Abstract.php';
* @category Zend
* @package Zend_Mail
* @subpackage Protocol
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Mail_Protocol_Smtp extends Zend_Mail_Protocol_Abstract

View File

@ -15,9 +15,9 @@
* @category Zend
* @package Zend_Mail
* @subpackage Protocol
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Crammd5.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
@ -33,7 +33,7 @@ require_once 'Zend/Mail/Protocol/Smtp.php';
* @category Zend
* @package Zend_Mail
* @subpackage Protocol
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Mail_Protocol_Smtp_Auth_Crammd5 extends Zend_Mail_Protocol_Smtp

View File

@ -15,9 +15,9 @@
* @category Zend
* @package Zend_Mail
* @subpackage Protocol
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Login.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
@ -33,7 +33,7 @@ require_once 'Zend/Mail/Protocol/Smtp.php';
* @category Zend
* @package Zend_Mail
* @subpackage Protocol
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Mail_Protocol_Smtp_Auth_Login extends Zend_Mail_Protocol_Smtp

View File

@ -15,9 +15,9 @@
* @category Zend
* @package Zend_Mail
* @subpackage Protocol
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Plain.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
@ -33,7 +33,7 @@ require_once 'Zend/Mail/Protocol/Smtp.php';
* @category Zend
* @package Zend_Mail
* @subpackage Protocol
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Mail_Protocol_Smtp_Auth_Plain extends Zend_Mail_Protocol_Smtp

View File

@ -14,15 +14,15 @@
*
* @category Zend
* @package Zend_Mail
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Storage.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
/**
* @category Zend
* @package Zend_Mail
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Mail_Storage
@ -31,6 +31,7 @@ class Zend_Mail_Storage
// system flags and other flags
const FLAG_PASSED = 'Passed';
const FLAG_SEEN = '\Seen';
const FLAG_UNSEEN = '\Unseen';
const FLAG_ANSWERED = '\Answered';
const FLAG_FLAGGED = '\Flagged';
const FLAG_DELETED = '\Deleted';

View File

@ -15,9 +15,9 @@
* @category Zend
* @package Zend_Mail
* @subpackage Storage
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Abstract.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
@ -25,7 +25,7 @@
* @category Zend
* @package Zend_Mail
* @subpackage Storage
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Mail_Storage_Abstract implements Countable, ArrayAccess, SeekableIterator
@ -124,8 +124,6 @@ abstract class Zend_Mail_Storage_Abstract implements Countable, ArrayAccess, See
*/
abstract public function getMessage($id);
abstract public function getFullMessage($id);
/**
* Get raw header of message or part

View File

@ -15,9 +15,9 @@
* @category Zend
* @package Zend_Mail
* @subpackage Storage
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Exception.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
@ -31,7 +31,7 @@ require_once 'Zend/Mail/Exception.php';
* @category Zend
* @package Zend_Mail
* @subpackage Storage
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Mail_Storage_Exception extends Zend_Mail_Exception

View File

@ -15,9 +15,9 @@
* @category Zend
* @package Zend_Mail
* @subpackage Storage
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Folder.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
@ -25,7 +25,7 @@
* @category Zend
* @package Zend_Mail
* @subpackage Storage
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Mail_Storage_Folder implements RecursiveIterator

View File

@ -15,9 +15,9 @@
* @category Zend
* @package Zend_Mail
* @subpackage Storage
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Interface.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
@ -25,7 +25,7 @@
* @category Zend
* @package Zend_Mail
* @subpackage Storage
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface Zend_Mail_Storage_Folder_Interface

View File

@ -15,9 +15,9 @@
* @category Zend
* @package Zend_Mail
* @subpackage Storage
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Maildir.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
@ -41,7 +41,7 @@ require_once 'Zend/Mail/Storage/Maildir.php';
* @category Zend
* @package Zend_Mail
* @subpackage Storage
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Mail_Storage_Folder_Maildir extends Zend_Mail_Storage_Maildir implements Zend_Mail_Storage_Folder_Interface

View File

@ -15,9 +15,9 @@
* @category Zend
* @package Zend_Mail
* @subpackage Storage
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Mbox.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
@ -41,7 +41,7 @@ require_once 'Zend/Mail/Storage/Mbox.php';
* @category Zend
* @package Zend_Mail
* @subpackage Storage
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Mail_Storage_Folder_Mbox extends Zend_Mail_Storage_Mbox implements Zend_Mail_Storage_Folder_Interface

View File

@ -15,9 +15,9 @@
* @category Zend
* @package Zend_Mail
* @subpackage Storage
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Imap.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
@ -60,7 +60,7 @@ require_once 'Zend/Mail/Storage.php';
* @category Zend
* @package Zend_Mail
* @subpackage Storage
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Mail_Storage_Imap extends Zend_Mail_Storage_Abstract
@ -88,6 +88,7 @@ class Zend_Mail_Storage_Imap extends Zend_Mail_Storage_Abstract
protected static $_knownFlags = array('\Passed' => Zend_Mail_Storage::FLAG_PASSED,
'\Answered' => Zend_Mail_Storage::FLAG_ANSWERED,
'\Seen' => Zend_Mail_Storage::FLAG_SEEN,
'\Unseen' => Zend_Mail_Storage::FLAG_UNSEEN,
'\Deleted' => Zend_Mail_Storage::FLAG_DELETED,
'\Draft' => Zend_Mail_Storage::FLAG_DRAFT,
'\Flagged' => Zend_Mail_Storage::FLAG_FLAGGED);
@ -99,6 +100,7 @@ class Zend_Mail_Storage_Imap extends Zend_Mail_Storage_Abstract
protected static $_searchFlags = array('\Recent' => 'RECENT',
'\Answered' => 'ANSWERED',
'\Seen' => 'SEEN',
'\Unseen' => 'UNSEEN',
'\Deleted' => 'DELETED',
'\Draft' => 'DRAFT',
'\Flagged' => 'FLAGGED');
@ -197,13 +199,6 @@ class Zend_Mail_Storage_Imap extends Zend_Mail_Storage_Abstract
return $this->_protocol->fetch('RFC822.HEADER', $id);
}
public function getFullMessage($id)
{
$data = $this->_protocol->fetch(array('RFC822.HEADER', 'RFC822.TEXT'), $id);
return $data['RFC822.HEADER'] . "\n\n" . $data['RFC822.TEXT'];
}
/*
* Get raw content of message or part
*

View File

@ -15,9 +15,9 @@
* @category Zend
* @package Zend_Mail
* @subpackage Storage
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Maildir.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
@ -41,7 +41,7 @@ require_once 'Zend/Mail/Storage.php';
* @category Zend
* @package Zend_Mail
* @subpackage Storage
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Mail_Storage_Maildir extends Zend_Mail_Storage_Abstract

View File

@ -15,9 +15,9 @@
* @category Zend
* @package Zend_Mail
* @subpackage Storage
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Mbox.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
@ -42,7 +42,7 @@ require_once 'Zend/Mail/Message/File.php';
* @category Zend
* @package Zend_Mail
* @subpackage Storage
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Mail_Storage_Mbox extends Zend_Mail_Storage_Abstract

View File

@ -15,9 +15,9 @@
* @category Zend
* @package Zend_Mail
* @subpackage Storage
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Pop3.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
@ -41,7 +41,7 @@ require_once 'Zend/Mail/Message.php';
* @category Zend
* @package Zend_Mail
* @subpackage Storage
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Mail_Storage_Pop3 extends Zend_Mail_Storage_Abstract

View File

@ -15,9 +15,9 @@
* @category Zend
* @package Zend_Mail
* @subpackage Storage
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Interface.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
@ -25,7 +25,7 @@
* @category Zend
* @package Zend_Mail
* @subpackage Storage
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

View File

@ -15,9 +15,9 @@
* @category Zend
* @package Zend_Mail
* @subpackage Storage
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Maildir.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
@ -36,7 +36,7 @@ require_once 'Zend/Mail/Storage/Writable/Interface.php';
* @category Zend
* @package Zend_Mail
* @subpackage Storage
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Mail_Storage_Writable_Maildir extends Zend_Mail_Storage_Folder_Maildir

View File

@ -15,9 +15,9 @@
* @category Zend
* @package Zend_Mail
* @subpackage Transport
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Abstract.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
@ -34,7 +34,7 @@ require_once 'Zend/Mime.php';
* @category Zend
* @package Zend_Mail
* @subpackage Transport
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Mail_Transport_Abstract

View File

@ -15,9 +15,9 @@
* @category Zend
* @package Zend_Mail
* @subpackage Transport
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Exception.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
@ -31,7 +31,7 @@ require_once 'Zend/Mail/Exception.php';
* @category Zend
* @package Zend_Mail
* @subpackage Transport
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Mail_Transport_Exception extends Zend_Mail_Exception

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Mail
* @subpackage Transport
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
@ -34,7 +34,7 @@ require_once 'Zend/Mail/Transport/Abstract.php';
* @category Zend
* @package Zend_Mail
* @subpackage Transport
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Mail_Transport_File extends Zend_Mail_Transport_Abstract

View File

@ -15,9 +15,9 @@
* @category Zend
* @package Zend_Mail
* @subpackage Transport
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Sendmail.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
@ -33,7 +33,7 @@ require_once 'Zend/Mail/Transport/Abstract.php';
* @category Zend
* @package Zend_Mail
* @subpackage Transport
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Mail_Transport_Sendmail extends Zend_Mail_Transport_Abstract

View File

@ -15,9 +15,9 @@
* @category Zend
* @package Zend_Mail
* @subpackage Transport
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Smtp.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
@ -45,7 +45,7 @@ require_once 'Zend/Mail/Transport/Abstract.php';
* @category Zend
* @package Zend_Mail
* @subpackage Transport
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Mail_Transport_Smtp extends Zend_Mail_Transport_Abstract

View File

@ -14,18 +14,17 @@
*
* @category Zend
* @package Zend_Mime
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Mime.php 24953 2012-06-13 19:09:58Z rob $
* @version $Id$
*/
/**
* Support class for MultiPart Mime Messages
*
* @category Zend
* @package Zend_Mime
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Mime
@ -45,58 +44,357 @@ class Zend_Mime
const MULTIPART_MIXED = 'multipart/mixed';
const MULTIPART_RELATED = 'multipart/related';
/**
* Boundary
*
* @var null|string
*/
protected $_boundary;
/**
* @var int
*/
protected static $makeUnique = 0;
// lookup-Tables for QuotedPrintable
/**
* Lookup-Tables for QuotedPrintable
*
* @var array
*/
public static $qpKeys = array(
"\x00","\x01","\x02","\x03","\x04","\x05","\x06","\x07",
"\x08","\x09","\x0A","\x0B","\x0C","\x0D","\x0E","\x0F",
"\x10","\x11","\x12","\x13","\x14","\x15","\x16","\x17",
"\x18","\x19","\x1A","\x1B","\x1C","\x1D","\x1E","\x1F",
"\x7F","\x80","\x81","\x82","\x83","\x84","\x85","\x86",
"\x87","\x88","\x89","\x8A","\x8B","\x8C","\x8D","\x8E",
"\x8F","\x90","\x91","\x92","\x93","\x94","\x95","\x96",
"\x97","\x98","\x99","\x9A","\x9B","\x9C","\x9D","\x9E",
"\x9F","\xA0","\xA1","\xA2","\xA3","\xA4","\xA5","\xA6",
"\xA7","\xA8","\xA9","\xAA","\xAB","\xAC","\xAD","\xAE",
"\xAF","\xB0","\xB1","\xB2","\xB3","\xB4","\xB5","\xB6",
"\xB7","\xB8","\xB9","\xBA","\xBB","\xBC","\xBD","\xBE",
"\xBF","\xC0","\xC1","\xC2","\xC3","\xC4","\xC5","\xC6",
"\xC7","\xC8","\xC9","\xCA","\xCB","\xCC","\xCD","\xCE",
"\xCF","\xD0","\xD1","\xD2","\xD3","\xD4","\xD5","\xD6",
"\xD7","\xD8","\xD9","\xDA","\xDB","\xDC","\xDD","\xDE",
"\xDF","\xE0","\xE1","\xE2","\xE3","\xE4","\xE5","\xE6",
"\xE7","\xE8","\xE9","\xEA","\xEB","\xEC","\xED","\xEE",
"\xEF","\xF0","\xF1","\xF2","\xF3","\xF4","\xF5","\xF6",
"\xF7","\xF8","\xF9","\xFA","\xFB","\xFC","\xFD","\xFE",
"\x00",
"\x01",
"\x02",
"\x03",
"\x04",
"\x05",
"\x06",
"\x07",
"\x08",
"\x09",
"\x0A",
"\x0B",
"\x0C",
"\x0D",
"\x0E",
"\x0F",
"\x10",
"\x11",
"\x12",
"\x13",
"\x14",
"\x15",
"\x16",
"\x17",
"\x18",
"\x19",
"\x1A",
"\x1B",
"\x1C",
"\x1D",
"\x1E",
"\x1F",
"\x7F",
"\x80",
"\x81",
"\x82",
"\x83",
"\x84",
"\x85",
"\x86",
"\x87",
"\x88",
"\x89",
"\x8A",
"\x8B",
"\x8C",
"\x8D",
"\x8E",
"\x8F",
"\x90",
"\x91",
"\x92",
"\x93",
"\x94",
"\x95",
"\x96",
"\x97",
"\x98",
"\x99",
"\x9A",
"\x9B",
"\x9C",
"\x9D",
"\x9E",
"\x9F",
"\xA0",
"\xA1",
"\xA2",
"\xA3",
"\xA4",
"\xA5",
"\xA6",
"\xA7",
"\xA8",
"\xA9",
"\xAA",
"\xAB",
"\xAC",
"\xAD",
"\xAE",
"\xAF",
"\xB0",
"\xB1",
"\xB2",
"\xB3",
"\xB4",
"\xB5",
"\xB6",
"\xB7",
"\xB8",
"\xB9",
"\xBA",
"\xBB",
"\xBC",
"\xBD",
"\xBE",
"\xBF",
"\xC0",
"\xC1",
"\xC2",
"\xC3",
"\xC4",
"\xC5",
"\xC6",
"\xC7",
"\xC8",
"\xC9",
"\xCA",
"\xCB",
"\xCC",
"\xCD",
"\xCE",
"\xCF",
"\xD0",
"\xD1",
"\xD2",
"\xD3",
"\xD4",
"\xD5",
"\xD6",
"\xD7",
"\xD8",
"\xD9",
"\xDA",
"\xDB",
"\xDC",
"\xDD",
"\xDE",
"\xDF",
"\xE0",
"\xE1",
"\xE2",
"\xE3",
"\xE4",
"\xE5",
"\xE6",
"\xE7",
"\xE8",
"\xE9",
"\xEA",
"\xEB",
"\xEC",
"\xED",
"\xEE",
"\xEF",
"\xF0",
"\xF1",
"\xF2",
"\xF3",
"\xF4",
"\xF5",
"\xF6",
"\xF7",
"\xF8",
"\xF9",
"\xFA",
"\xFB",
"\xFC",
"\xFD",
"\xFE",
"\xFF"
);
/**
* @var array
*/
public static $qpReplaceValues = array(
"=00","=01","=02","=03","=04","=05","=06","=07",
"=08","=09","=0A","=0B","=0C","=0D","=0E","=0F",
"=10","=11","=12","=13","=14","=15","=16","=17",
"=18","=19","=1A","=1B","=1C","=1D","=1E","=1F",
"=7F","=80","=81","=82","=83","=84","=85","=86",
"=87","=88","=89","=8A","=8B","=8C","=8D","=8E",
"=8F","=90","=91","=92","=93","=94","=95","=96",
"=97","=98","=99","=9A","=9B","=9C","=9D","=9E",
"=9F","=A0","=A1","=A2","=A3","=A4","=A5","=A6",
"=A7","=A8","=A9","=AA","=AB","=AC","=AD","=AE",
"=AF","=B0","=B1","=B2","=B3","=B4","=B5","=B6",
"=B7","=B8","=B9","=BA","=BB","=BC","=BD","=BE",
"=BF","=C0","=C1","=C2","=C3","=C4","=C5","=C6",
"=C7","=C8","=C9","=CA","=CB","=CC","=CD","=CE",
"=CF","=D0","=D1","=D2","=D3","=D4","=D5","=D6",
"=D7","=D8","=D9","=DA","=DB","=DC","=DD","=DE",
"=DF","=E0","=E1","=E2","=E3","=E4","=E5","=E6",
"=E7","=E8","=E9","=EA","=EB","=EC","=ED","=EE",
"=EF","=F0","=F1","=F2","=F3","=F4","=F5","=F6",
"=F7","=F8","=F9","=FA","=FB","=FC","=FD","=FE",
"=00",
"=01",
"=02",
"=03",
"=04",
"=05",
"=06",
"=07",
"=08",
"=09",
"=0A",
"=0B",
"=0C",
"=0D",
"=0E",
"=0F",
"=10",
"=11",
"=12",
"=13",
"=14",
"=15",
"=16",
"=17",
"=18",
"=19",
"=1A",
"=1B",
"=1C",
"=1D",
"=1E",
"=1F",
"=7F",
"=80",
"=81",
"=82",
"=83",
"=84",
"=85",
"=86",
"=87",
"=88",
"=89",
"=8A",
"=8B",
"=8C",
"=8D",
"=8E",
"=8F",
"=90",
"=91",
"=92",
"=93",
"=94",
"=95",
"=96",
"=97",
"=98",
"=99",
"=9A",
"=9B",
"=9C",
"=9D",
"=9E",
"=9F",
"=A0",
"=A1",
"=A2",
"=A3",
"=A4",
"=A5",
"=A6",
"=A7",
"=A8",
"=A9",
"=AA",
"=AB",
"=AC",
"=AD",
"=AE",
"=AF",
"=B0",
"=B1",
"=B2",
"=B3",
"=B4",
"=B5",
"=B6",
"=B7",
"=B8",
"=B9",
"=BA",
"=BB",
"=BC",
"=BD",
"=BE",
"=BF",
"=C0",
"=C1",
"=C2",
"=C3",
"=C4",
"=C5",
"=C6",
"=C7",
"=C8",
"=C9",
"=CA",
"=CB",
"=CC",
"=CD",
"=CE",
"=CF",
"=D0",
"=D1",
"=D2",
"=D3",
"=D4",
"=D5",
"=D6",
"=D7",
"=D8",
"=D9",
"=DA",
"=DB",
"=DC",
"=DD",
"=DE",
"=DF",
"=E0",
"=E1",
"=E2",
"=E3",
"=E4",
"=E5",
"=E6",
"=E7",
"=E8",
"=E9",
"=EA",
"=EB",
"=EC",
"=ED",
"=EE",
"=EF",
"=F0",
"=F1",
"=F2",
"=F3",
"=F4",
"=F5",
"=F6",
"=F7",
"=F8",
"=F9",
"=FA",
"=FB",
"=FC",
"=FD",
"=FE",
"=FF"
);
/**
* @var string
*/
public static $qpKeysString =
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF";
@ -118,19 +416,21 @@ class Zend_Mime
* Encode a given string with the QUOTED_PRINTABLE mechanism and wrap the lines.
*
* @param string $str
* @param int $lineLength Defaults to {@link LINELENGTH}
* @param int $lineEnd Defaults to {@link LINEEND}
* @param int $lineLength Line length; defaults to {@link LINELENGTH}
* @param string $lineEnd Line end; defaults to {@link LINEEND}
* @return string
*/
public static function encodeQuotedPrintable($str,
public static function encodeQuotedPrintable(
$str,
$lineLength = self::LINELENGTH,
$lineEnd = self::LINEEND)
$lineEnd = self::LINEEND
)
{
$out = '';
$str = self::_encodeQuotedPrintable($str);
// Split encoded text into separate lines
while(strlen($str) > 0) {
while (strlen($str) > 0) {
$ptr = strlen($str);
if ($ptr > $lineLength) {
$ptr = $lineLength;
@ -154,6 +454,7 @@ class Zend_Mime
$out = rtrim($out, $lineEnd);
$out = rtrim($out, '=');
return $out;
}
@ -168,6 +469,7 @@ class Zend_Mime
$str = str_replace('=', '=3D', $str);
$str = str_replace(self::$qpKeys, self::$qpReplaceValues, $str);
$str = rtrim($str);
return $str;
}
@ -179,55 +481,58 @@ class Zend_Mime
*
* @param string $str
* @param string $charset
* @param int $lineLength Defaults to {@link LINELENGTH}
* @param int $lineEnd Defaults to {@link LINEEND}
* @param int $lineLength Line length; defaults to {@link LINELENGTH}
* @param string $lineEnd Line end; defaults to {@link LINEEND}
* @return string
*/
public static function encodeQuotedPrintableHeader($str, $charset,
$lineLength = self::LINELENGTH,
$lineEnd = self::LINEEND)
public static function encodeQuotedPrintableHeader(
$str, $charset, $lineLength = self::LINELENGTH, $lineEnd = self::LINEEND
)
{
// Reduce line-length by the length of the required delimiter, charsets and encoding
$prefix = sprintf('=?%s?Q?', $charset);
$lineLength = $lineLength-strlen($prefix)-3;
$lineLength = $lineLength - strlen($prefix) - 3;
$str = self::_encodeQuotedPrintable($str);
// Mail-Header required chars have to be encoded also:
$str = str_replace(array('?', ' ', '_', ','), array('=3F', '=20', '=5F', '=2C'), $str);
$str = str_replace(
array('?', ' ', '_', ','), array('=3F', '=20', '=5F', '=2C'), $str
);
// initialize first line, we need it anyways
$lines = array(0 => "");
// Split encoded text into separate lines
$tmp = "";
while(strlen($str) > 0) {
$currentLine = max(count($lines)-1, 0);
while (strlen($str) > 0) {
$currentLine = max(count($lines) - 1, 0);
$token = self::getNextQuotedPrintableToken($str);
$str = substr($str, strlen($token));
$tmp .= $token;
if($token == '=20') {
if ($token == '=20') {
// only if we have a single char token or space, we can append the
// tempstring it to the current line or start a new line if necessary.
if(strlen($lines[$currentLine].$tmp) > $lineLength) {
$lines[$currentLine+1] = $tmp;
if (strlen($lines[$currentLine] . $tmp) > $lineLength) {
$lines[$currentLine + 1] = $tmp;
} else {
$lines[$currentLine] .= $tmp;
}
$tmp = "";
}
// don't forget to append the rest to the last line
if(strlen($str) == 0) {
if (strlen($str) == 0) {
$lines[$currentLine] .= $tmp;
}
}
// assemble the lines together by pre- and appending delimiters, charset, encoding.
for($i = 0; $i < count($lines); $i++) {
$lines[$i] = " ".$prefix.$lines[$i]."?=";
for ($i = 0; $i < count($lines); $i++) {
$lines[$i] = " " . $prefix . $lines[$i] . "?=";
}
$str = trim(implode($lineEnd, $lines));
return $str;
}
@ -239,11 +544,12 @@ class Zend_Mime
*/
private static function getNextQuotedPrintableToken($str)
{
if(substr($str, 0, 1) == "=") {
if (substr($str, 0, 1) == "=") {
$token = substr($str, 0, 3);
} else {
$token = substr($str, 0, 1);
}
return $token;
}
@ -252,22 +558,24 @@ class Zend_Mime
*
* @param string $str
* @param string $charset
* @param int $lineLength Defaults to {@link LINELENGTH}
* @param int $lineEnd Defaults to {@link LINEEND}
* @param int $lineLength Line length; defaults to {@link LINELENGTH}
* @param string $lineEnd Line end; defaults to {@link LINEEND}
* @return string
*/
public static function encodeBase64Header($str,
$charset,
$lineLength = self::LINELENGTH,
$lineEnd = self::LINEEND)
public static function encodeBase64Header(
$str, $charset, $lineLength = self::LINELENGTH, $lineEnd = self::LINEEND
)
{
$prefix = '=?' . $charset . '?B?';
$suffix = '?=';
$remainingLength = $lineLength - strlen($prefix) - strlen($suffix);
$encodedValue = self::encodeBase64($str, $remainingLength, $lineEnd);
$encodedValue = str_replace($lineEnd, $suffix . $lineEnd . ' ' . $prefix, $encodedValue);
$encodedValue = str_replace(
$lineEnd, $suffix . $lineEnd . ' ' . $prefix, $encodedValue
);
$encodedValue = $prefix . $encodedValue . $suffix;
return $encodedValue;
}
@ -276,13 +584,13 @@ class Zend_Mime
* according to the maximum linelength.
*
* @param string $str
* @param int $lineLength Defaults to {@link LINELENGTH}
* @param int $lineEnd Defaults to {@link LINEEND}
* @param int $lineLength Line length; defaults to {@link LINELENGTH}
* @param string $lineEnd Line end; defaults to {@link LINEEND}
* @return string
*/
public static function encodeBase64($str,
$lineLength = self::LINELENGTH,
$lineEnd = self::LINEEND)
public static function encodeBase64(
$str, $lineLength = self::LINELENGTH, $lineEnd = self::LINEEND
)
{
return rtrim(chunk_split(base64_encode($str), $lineLength, $lineEnd));
}
@ -291,8 +599,6 @@ class Zend_Mime
* Constructor
*
* @param null|string $boundary
* @access public
* @return void
*/
public function __construct($boundary = null)
{
@ -309,7 +615,7 @@ class Zend_Mime
*
* @param string $str
* @param string $encoding
* @param string $EOL EOL string; defaults to {@link Zend_Mime::LINEEND}
* @param string $EOL Line end; defaults to {@link Zend_Mime::LINEEND}
* @return string
*/
public static function encode($str, $encoding, $EOL = self::LINEEND)
@ -343,8 +649,7 @@ class Zend_Mime
/**
* Return a MIME boundary line
*
* @param mixed $EOL Defaults to {@link LINEEND}
* @access public
* @param string $EOL Line end; defaults to {@link LINEEND}
* @return string
*/
public function boundaryLine($EOL = self::LINEEND)
@ -355,7 +660,7 @@ class Zend_Mime
/**
* Return MIME ending
*
* @access public
* @param string $EOL Line end; defaults to {@link LINEEND}
* @return string
*/
public function mimeEnd($EOL = self::LINEEND)

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Mime
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Decode.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
/**
@ -27,7 +27,7 @@ require_once 'Zend/Mime.php';
/**
* @category Zend
* @package Zend_Mime
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Mime_Decode
@ -68,12 +68,13 @@ class Zend_Mime_Decode
// no more parts, find end boundary
$p = strpos($body, '--' . $boundary . '--', $start);
if ($p===false) {
if ($p === false) {
throw new Zend_Exception('Not a valid Mime Message: End Missing');
}
// the remaining part also needs to be parsed:
$res[] = substr($body, $start, $p-$start);
$res[] = substr($body, $start, $p - $start);
return $res;
}
@ -87,7 +88,9 @@ class Zend_Mime_Decode
* @return array|null parts as array('header' => array(name => value), 'body' => content), null if no parts found
* @throws Zend_Exception
*/
public static function splitMessageStruct($message, $boundary, $EOL = Zend_Mime::LINEEND)
public static function splitMessageStruct(
$message, $boundary, $EOL = Zend_Mime::LINEEND
)
{
$parts = self::splitMime($message, $boundary);
if (count($parts) <= 0) {
@ -96,9 +99,12 @@ class Zend_Mime_Decode
$result = array();
foreach ($parts as $part) {
self::splitMessage($part, $headers, $body, $EOL);
$result[] = array('header' => $headers,
'body' => $body );
$result[] = array(
'header' => $headers,
'body' => $body
);
}
return $result;
}
@ -114,14 +120,25 @@ class Zend_Mime_Decode
* @param string $EOL EOL string; defaults to {@link Zend_Mime::LINEEND}
* @return null
*/
public static function splitMessage($message, &$headers, &$body, $EOL = Zend_Mime::LINEEND)
public static function splitMessage(
$message, &$headers, &$body, $EOL = Zend_Mime::LINEEND
)
{
// check for valid header at first line
$firstline = strtok($message, "\n");
if (!preg_match('%^[^\s]+[^:]*:%', $firstline)) {
$headers = array();
// TODO: we're ignoring \r for now - is this function fast enough and is it safe to asume noone needs \r?
$body = str_replace(array("\r", "\n"), array('', $EOL), $message);
$body = str_replace(
array(
"\r",
"\n"
), array(
'',
$EOL
), $message
);
return;
}
@ -130,19 +147,26 @@ class Zend_Mime_Decode
if (strpos($message, $EOL . $EOL)) {
list($headers, $body) = explode($EOL . $EOL, $message, 2);
// next is the standard new line
} else if ($EOL != "\r\n" && strpos($message, "\r\n\r\n")) {
} else {
if ($EOL != "\r\n" && strpos($message, "\r\n\r\n")) {
list($headers, $body) = explode("\r\n\r\n", $message, 2);
// next is the other "standard" new line
} else if ($EOL != "\n" && strpos($message, "\n\n")) {
} else {
if ($EOL != "\n" && strpos($message, "\n\n")) {
list($headers, $body) = explode("\n\n", $message, 2);
// at last resort find anything that looks like a new line
} else {
@list($headers, $body) = @preg_split("%([\r\n]+)\\1%U", $message, 2);
@list($headers, $body) =
@preg_split("%([\r\n]+)\\1%U", $message, 2);
}
}
}
$headers = iconv_mime_decode_headers($headers, ICONV_MIME_DECODE_CONTINUE_ON_ERROR);
$headers = iconv_mime_decode_headers(
$headers, ICONV_MIME_DECODE_CONTINUE_ON_ERROR
);
if ($headers === false ) {
if ($headers === false) {
// an error occurs during the decoding
return;
}
@ -162,7 +186,10 @@ class Zend_Mime_Decode
$headers[$lower][] = $header;
continue;
}
$headers[$lower] = array($headers[$lower], $header);
$headers[$lower] = array(
$headers[$lower],
$header
);
}
}
@ -181,13 +208,15 @@ class Zend_Mime_Decode
/**
* split a header field like content type in its different parts
*
* @param string $type header field
* @param string $field
* @param string $wantedPart the wanted part, else an array with all parts is returned
* @param string $firstName key name for the first part
* @return string|array wanted part or all parts as array($firstName => firstPart, partname => value)
* @param int|string $firstName key name for the first part
* @throws Zend_Exception
* @return string|array wanted part or all parts as array($firstName => firstPart, partname => value)
*/
public static function splitHeaderField($field, $wantedPart = null, $firstName = 0)
public static function splitHeaderField(
$field, $wantedPart = null, $firstName = 0
)
{
$wantedPart = strtolower($wantedPart);
$firstName = strtolower($firstName);
@ -195,6 +224,7 @@ class Zend_Mime_Decode
// special case - a bit optimized
if ($firstName === $wantedPart) {
$field = strtok($field, ';');
return $field[0] == '"' ? substr($field, 1, -1) : $field;
}
@ -211,8 +241,10 @@ class Zend_Mime_Decode
if ($matches[2][$key][0] != '"') {
return $matches[2][$key];
}
return substr($matches[2][$key], 1, -1);
}
return null;
}
@ -234,8 +266,8 @@ class Zend_Mime_Decode
*
* The charset of the returned string depends on your iconv settings.
*
* @param string encoded string
* @return string decoded string
* @param string $string Encoded string
* @return string Decoded string
*/
public static function decodeQuotedPrintable($string)
{

View File

@ -14,24 +14,23 @@
*
* @category Zend
* @package Zend_Mime
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Exception.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
/**
* Zend_Exception
*/
require_once 'Zend/Exception.php';
/**
* @category Zend
* @package Zend_Mime
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Mime_Exception extends Zend_Exception
{}
{
}

View File

@ -14,12 +14,11 @@
*
* @category Zend
* @package Zend_Mime
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Message.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
/**
* Zend_Mime
*/
@ -30,17 +29,26 @@ require_once 'Zend/Mime.php';
*/
require_once 'Zend/Mime/Part.php';
/**
* @category Zend
* @package Zend_Mime
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Mime_Message
{
/**
* The Zend_Mime_Parts of the message
*
* @var array
*/
protected $_parts = array();
/**
* The Zend_Mime object for the message
*
* @var Zend_Mime|null
*/
protected $_mime = null;
/**
@ -134,7 +142,7 @@ class Zend_Mime_Message
*/
public function generateMessage($EOL = Zend_Mime::LINEEND)
{
if (! $this->isMultiPart()) {
if (!$this->isMultiPart()) {
$body = array_shift($this->_parts);
$body = $body->getContent($EOL);
} else {
@ -172,6 +180,7 @@ class Zend_Mime_Message
* Get the headers of a given part as a string
*
* @param int $partnum
* @param string $EOL
* @return string
*/
public function getPartHeaders($partnum, $EOL = Zend_Mime::LINEEND)
@ -183,6 +192,7 @@ class Zend_Mime_Message
* Get the (encoded) content of a given part as a string
*
* @param int $partnum
* @param string $EOL
* @return string
*/
public function getPartContent($partnum, $EOL = Zend_Mime::LINEEND)
@ -197,6 +207,7 @@ class Zend_Mime_Message
*
* @param string $body
* @param string $boundary
* @throws Zend_Exception
* @return array
*/
protected static function _disassembleMime($body, $boundary)
@ -206,7 +217,7 @@ class Zend_Mime_Message
// find every mime part limiter and cut out the
// string before it.
// the part before the first boundary string is discarded:
$p = strpos($body, '--'.$boundary."\n", $start);
$p = strpos($body, '--' . $boundary . "\n", $start);
if ($p === false) {
// no parts found!
return array();
@ -215,19 +226,21 @@ class Zend_Mime_Message
// position after first boundary line
$start = $p + 3 + strlen($boundary);
while (($p = strpos($body, '--' . $boundary . "\n", $start)) !== false) {
$res[] = substr($body, $start, $p-$start);
while (($p = strpos($body, '--' . $boundary . "\n", $start))
!== false) {
$res[] = substr($body, $start, $p - $start);
$start = $p + 3 + strlen($boundary);
}
// no more parts, find end boundary
$p = strpos($body, '--' . $boundary . '--', $start);
if ($p===false) {
if ($p === false) {
throw new Zend_Exception('Not a valid Mime Message: End Missing');
}
// the remaining part also needs to be parsed:
$res[] = substr($body, $start, $p-$start);
$res[] = substr($body, $start, $p - $start);
return $res;
}
@ -238,9 +251,12 @@ class Zend_Mime_Message
* @param string $message
* @param string $boundary
* @param string $EOL EOL string; defaults to {@link Zend_Mime::LINEEND}
* @throws Zend_Exception
* @return Zend_Mime_Message
*/
public static function createFromMessage($message, $boundary, $EOL = Zend_Mime::LINEEND)
public static function createFromMessage(
$message, $boundary, $EOL = Zend_Mime::LINEEND
)
{
require_once 'Zend/Mime/Decode.php';
$parts = Zend_Mime_Decode::splitMessageStruct($message, $boundary, $EOL);
@ -253,7 +269,7 @@ class Zend_Mime_Message
/**
* @todo check for characterset and filename
*/
switch(strtolower($key)) {
switch (strtolower($key)) {
case 'content-type':
$newPart->type = $value;
break;
@ -261,7 +277,7 @@ class Zend_Mime_Message
$newPart->encoding = $value;
break;
case 'content-id':
$newPart->id = trim($value,'<>');
$newPart->id = trim($value, '<>');
break;
case 'content-disposition':
$newPart->disposition = $value;
@ -276,11 +292,14 @@ class Zend_Mime_Message
$newPart->language = $value;
break;
default:
throw new Zend_Exception('Unknown header ignored for MimePart:' . $key);
throw new Zend_Exception(
'Unknown header ignored for MimePart:' . $key
);
}
}
$res->addPart($newPart);
}
return $res;
}
}

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Mime
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Part.php 24593 2012-01-05 20:35:02Z matthew $
* @version $Id$
*/
/**
@ -29,24 +29,93 @@ require_once 'Zend/Mime.php';
*
* @category Zend
* @package Zend_Mime
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Mime_Part {
class Zend_Mime_Part
{
/**
* Type
*
* @var string
*/
public $type = Zend_Mime::TYPE_OCTETSTREAM;
public $encoding = Zend_Mime::ENCODING_8BIT;
public $id;
public $disposition;
public $filename;
public $description;
public $charset;
public $boundary;
public $location;
public $language;
protected $_content;
protected $_isStream = false;
/**
* Encoding
*
* @var string
*/
public $encoding = Zend_Mime::ENCODING_8BIT;
/**
* ID
*
* @var string
*/
public $id;
/**
* Disposition
*
* @var string
*/
public $disposition;
/**
* Filename
*
* @var string
*/
public $filename;
/**
* Description
*
* @var string
*/
public $description;
/**
* Character set
*
* @var string
*/
public $charset;
/**
* Boundary
*
* @var string
*/
public $boundary;
/**
* Location
*
* @var string
*/
public $location;
/**
* Language
*
* @var string
*/
public $language;
/**
* Content
*
* @var mixed
*/
protected $_content;
/**
* @var bool
*/
protected $_isStream = false;
/**
* create a new Mime Part.
@ -86,14 +155,16 @@ class Zend_Mime_Part {
* if this was created with a stream, return a filtered stream for
* reading the content. very useful for large file attachments.
*
* @return stream
* @return mixed Stream
* @throws Zend_Mime_Exception if not a stream or unable to append filter
*/
public function getEncodedStream()
{
if (!$this->_isStream) {
require_once 'Zend/Mime/Exception.php';
throw new Zend_Mime_Exception('Attempt to get a stream from a string part');
throw new Zend_Mime_Exception(
'Attempt to get a stream from a string part'
);
}
//stream_filter_remove(); // ??? is that right?
@ -110,9 +181,12 @@ class Zend_Mime_Part {
);
if (!is_resource($filter)) {
require_once 'Zend/Mime/Exception.php';
throw new Zend_Mime_Exception('Failed to append quoted-printable filter');
throw new Zend_Mime_Exception(
'Failed to append quoted-printable filter'
);
}
break;
case Zend_Mime::ENCODING_BASE64:
$filter = stream_filter_append(
$this->_content,
@ -125,18 +199,24 @@ class Zend_Mime_Part {
);
if (!is_resource($filter)) {
require_once 'Zend/Mime/Exception.php';
throw new Zend_Mime_Exception('Failed to append base64 filter');
throw new Zend_Mime_Exception(
'Failed to append base64 filter'
);
}
break;
default:
}
return $this->_content;
}
/**
* Get the Content of the current Mime Part in the given encoding.
*
* @return String
* @param string $EOL Line end; defaults to {@link Zend_Mime::LINEEND}
* @throws Zend_Mime_Exception
* @return string
*/
public function getContent($EOL = Zend_Mime::LINEEND)
{
@ -149,6 +229,7 @@ class Zend_Mime_Part {
/**
* Get the RAW unencoded content from this part
*
* @return string
*/
public function getRawContent()
@ -163,7 +244,7 @@ class Zend_Mime_Part {
/**
* Create and return the array of headers for this MIME part
*
* @access public
* @param string $EOL Line end; defaults to {@link Zend_Mime::LINEEND}
* @return array
*/
public function getHeadersArray($EOL = Zend_Mime::LINEEND)
@ -180,14 +261,23 @@ class Zend_Mime_Part {
. " boundary=\"" . $this->boundary . '"';
}
$headers[] = array('Content-Type', $contentType);
$headers[] = array(
'Content-Type',
$contentType
);
if ($this->encoding) {
$headers[] = array('Content-Transfer-Encoding', $this->encoding);
$headers[] = array(
'Content-Transfer-Encoding',
$this->encoding
);
}
if ($this->id) {
$headers[] = array('Content-ID', '<' . $this->id . '>');
$headers[] = array(
'Content-ID',
'<' . $this->id . '>'
);
}
if ($this->disposition) {
@ -195,19 +285,31 @@ class Zend_Mime_Part {
if ($this->filename) {
$disposition .= '; filename="' . $this->filename . '"';
}
$headers[] = array('Content-Disposition', $disposition);
$headers[] = array(
'Content-Disposition',
$disposition
);
}
if ($this->description) {
$headers[] = array('Content-Description', $this->description);
$headers[] = array(
'Content-Description',
$this->description
);
}
if ($this->location) {
$headers[] = array('Content-Location', $this->location);
$headers[] = array(
'Content-Location',
$this->location
);
}
if ($this->language){
$headers[] = array('Content-Language', $this->language);
if ($this->language) {
$headers[] = array(
'Content-Language',
$this->language
);
}
return $headers;
@ -216,7 +318,8 @@ class Zend_Mime_Part {
/**
* Return the headers for this part as a string
*
* @return String
* @param string $EOL Line end; defaults to {@link Zend_Mime::LINEEND}
* @return string
*/
public function getHeaders($EOL = Zend_Mime::LINEEND)
{