Author: Alexandru Stanoi Date: 2007-01-19 16:03:57 +0100 (Fri, 19 Jan 2007) New Revision: 4535
Log: - Added support for multipart/report and message/delivery-status mail parts (connected to issue #8694). Added: trunk/Mail/src/parser/parts/delivery_status_parser.php trunk/Mail/src/parser/parts/multipart_report_parser.php trunk/Mail/src/parts/delivery_status.php trunk/Mail/src/parts/multiparts/multipart_report.php trunk/Mail/tests/parser/data/various/multipart-report trunk/Mail/tests/parser/data/various/multipart-report-multiple-deliveries Modified: trunk/Mail/ChangeLog trunk/Mail/src/mail.php trunk/Mail/src/mail_autoload.php trunk/Mail/src/parser/interfaces/part_parser.php trunk/Mail/tests/mail_test.php trunk/Mail/tests/parser/parser_test.php trunk/Mail/tests/parts/multipart_test.php Modified: trunk/Mail/ChangeLog =================================================================== --- trunk/Mail/ChangeLog 2007-01-19 12:02:40 UTC (rev 4534) +++ trunk/Mail/ChangeLog 2007-01-19 15:03:57 UTC (rev 4535) @@ -8,8 +8,9 @@ - Added walkParts() to ezcMail and the class ezcMailPartWalkContext which can be used to walk through all the parts in a mail and execute a callback function on each part (for example save mail parts to disk or a database). +- Added support for multipart/report and message/delivery-status mail parts + (connected to issue #8694). - 1.2.1 - [RELEASEDATE] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Modified: trunk/Mail/src/mail.php =================================================================== --- trunk/Mail/src/mail.php 2007-01-19 12:02:40 UTC (rev 4534) +++ trunk/Mail/src/mail.php 2007-01-19 15:03:57 UTC (rev 4535) @@ -457,6 +457,7 @@ case 'ezcMailMultipartMixed': case 'ezcMailMultipartAlternative': case 'ezcMailMultipartDigest': + case 'ezcMailMultipartReport': foreach ( $mail->getParts() as $part ) { $this->walkParts( $context, $part ); @@ -484,6 +485,7 @@ case 'ezcMailText': case 'ezcMailFile': + case 'ezcMailDeliveryStatus': if ( empty( $context->filter ) || in_array( $className, $context->filter ) ) { call_user_func( $context->callbackFunction, $context, $mail ); Modified: trunk/Mail/src/mail_autoload.php =================================================================== --- trunk/Mail/src/mail_autoload.php 2007-01-19 12:02:40 UTC (rev 4534) +++ trunk/Mail/src/mail_autoload.php 2007-01-19 15:03:57 UTC (rev 4535) @@ -24,11 +24,13 @@ 'ezcMailStreamFile' => 'Mail/parts/fileparts/stream_file.php', 'ezcMailRfc822Digest' => 'Mail/parts/rfc822_digest.php', 'ezcMailText' => 'Mail/parts/text.php', + 'ezcMailDeliveryStatus' => 'Mail/parts/delivery_status.php', 'ezcMailMultipart' => 'Mail/parts/multipart.php', 'ezcMailMultipartAlternative' => 'Mail/parts/multiparts/multipart_alternative.php', 'ezcMailMultipartMixed' => 'Mail/parts/multiparts/multipart_mixed.php', 'ezcMailMultipartRelated' => 'Mail/parts/multiparts/multipart_related.php', 'ezcMailMultipartDigest' => 'Mail/parts/multiparts/multipart_digest.php', + 'ezcMailMultipartReport' => 'Mail/parts/multiparts/multipart_report.php', 'ezcMailTransportConnection' => 'Mail/transports/transport_connection.php', 'ezcMailTransportMta' => 'Mail/transports/mta/transport_mta.php', 'ezcMailMtaTransport' => 'Mail/transports/mta/transport_mta.php', @@ -60,8 +62,10 @@ 'ezcMailMultipartDigestParser' => 'Mail/parser/parts/multipart_digest_parser.php', 'ezcMailMultipartAlternativeParser' => 'Mail/parser/parts/multipart_alternative_parser.php', 'ezcMailMultipartRelatedParser' => 'Mail/parser/parts/multipart_related_parser.php', + 'ezcMailMultipartReportParser' => 'Mail/parser/parts/multipart_report_parser.php', 'ezcMailFileParser' => 'Mail/parser/parts/file_parser.php', 'ezcMailRfc822DigestParser' => 'Mail/parser/parts/rfc822_digest_parser.php', + 'ezcMailDeliveryStatusParser' => 'Mail/parser/parts/delivery_status_parser.php', 'ezcMailHeadersHolder' => 'Mail/parser/headers_holder.php', 'ezcMailParserSet' => 'Mail/parser/interfaces/parser_set.php', 'ezcMailParserShutdownHandler' => 'Mail/parser/shutdown_handler.php', Modified: trunk/Mail/src/parser/interfaces/part_parser.php =================================================================== --- trunk/Mail/src/parser/interfaces/part_parser.php 2007-01-19 12:02:40 UTC (rev 4534) +++ trunk/Mail/src/parser/interfaces/part_parser.php 2007-01-19 15:03:57 UTC (rev 4535) @@ -105,14 +105,20 @@ break; case 'message': - if ( $subType == "rfc822" ) + switch ( $subType ) { - $bodyParser = new ezcMailRfc822DigestParser( $headers ); + case "rfc822": + $bodyParser = new ezcMailRfc822DigestParser( $headers ); + break; + + case "delivery-status": + $bodyParser = new ezcMailDeliveryStatusParser( $headers ); + break; + + default: + $bodyParser = new ezcMailTextParser( $subType, $headers ); + break; } - else - { - $bodyParser = new ezcMailTextParser( $subType, $headers ); - } break; case 'text': @@ -133,7 +139,10 @@ break; case 'digest': $bodyParser = new ezcMailMultipartDigestParser( $headers ); - break; + break; + case 'report': + $bodyParser = new ezcMailMultipartReportParser( $headers ); + break; default: $bodyParser = new ezcMailMultipartMixedParser( $headers ); break; Added: trunk/Mail/src/parser/parts/delivery_status_parser.php =================================================================== --- trunk/Mail/src/parser/parts/delivery_status_parser.php 2007-01-19 12:02:40 UTC (rev 4534) +++ trunk/Mail/src/parser/parts/delivery_status_parser.php 2007-01-19 15:03:57 UTC (rev 4535) @@ -0,0 +1,105 @@ +<?php +/** + * File containing the ezcMailDeliveryStatusParser class + * + * @package Mail + * @version //autogen// + * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + */ + +/** + * Parses mail parts of type "delivery-status". + * + * @package Mail + * @version //autogen// + * @access private + */ +class ezcMailDeliveryStatusParser extends ezcMailPartParser +{ + /** + * This mail part will be returned by the method finish(). + * + * @var ezcMailDeliveryStatus + */ + private $part = null; + + /** + * The current section of the parsing of delivery-status headers. + * + * 0 = the per-message section + * 1, ... = the per-recipient section + * + * @var int + */ + private $section; + + /** + * Constructs a new ezcMailDeliveryStatusParser with additional headers $headers. + * + * @param ezcMailHeadersHolder $headers + */ + public function __construct( ezcMailHeadersHolder $headers ) + { + $this->headers = $headers; + $this->section = 0; + $this->part = new ezcMailDeliveryStatus(); + } + + /** + * Parses each line of the mail part. + * + * @param string $line + */ + public function parseBody( $line ) + { + $this->parseHeader( $line, $this->headers ); + } + + /** + * Parses the header given by $line. + * + * @param string $line + * @param ezcMailHeadersHolder $headers + */ + protected function parseHeader( $line, ezcMailHeadersHolder $headers ) + { + $matches = array(); + preg_match_all( "/^([\w-_]*): (.*)/", $line, $matches, PREG_SET_ORDER ); + if ( count( $matches ) > 0 ) + { + $this->lastParsedHeader = $matches[0][1]; + $this->headerValue = trim( $matches[0][2] ); + } + else if ( isset( $this->lastParsedHeader ) && $this->lastParsedHeader !== null ) // take care of folding + { + $this->headerValue .= $line; + } + if ( strlen( trim( $line ) ) == 0 ) + { + $this->section++; + $this->part->createRecipient(); + return; + } + if ( $this->section == 0 ) + { + $this->part->message[$this->lastParsedHeader] = $this->headerValue; + } + else + { + $this->part->recipients[$this->section - 1][$this->lastParsedHeader] = $this->headerValue; + } + } + + /** + * Returns the ezcMailDeliveryStatus part corresponding to the parsed message. + * + * @return ezcMailDeliveryStatus + */ + public function finish() + { + unset( $this->part->recipients[$this->section - 1] ); // because one extra recipient is created in parseHeader() + return $this->part; + } +} +?> Property changes on: trunk/Mail/src/parser/parts/delivery_status_parser.php ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/Mail/src/parser/parts/multipart_report_parser.php =================================================================== --- trunk/Mail/src/parser/parts/multipart_report_parser.php 2007-01-19 12:02:40 UTC (rev 4534) +++ trunk/Mail/src/parser/parts/multipart_report_parser.php 2007-01-19 15:03:57 UTC (rev 4535) @@ -0,0 +1,88 @@ +<?php +/** + * File containing the ezcMailMultipartReportParser class + * + * @package Mail + * @version //autogen// + * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + */ + +/** + * Parses multipart/report mail parts. + * + * @package Mail + * @version //autogen// + * @access private + */ +class ezcMailMultipartReportParser extends ezcMailMultipartParser +{ + /** + * Holds the ezcMailMultipartReport part corresponding to the data parsed with this parser. + * + * @var ezcMailMultipartReport + */ + private $report; + + /** + * Holds the mail parts which will be part of the returned multipart report. + * + * @var array(ezcMailPart) + */ + private $parts; + + /** + * Constructs a new ezcMailMultipartReportParser. + * + * @param ezcMailHeadersHolder $headers + */ + public function __construct( ezcMailHeadersHolder $headers ) + { + parent::__construct( $headers ); + $this->report = new ezcMailMultipartReport(); + $this->parts = array(); + preg_match( '/\s*report-type="?([^;"]*);?/i', + $this->headers['Content-Type'], + $parameters ); + if ( count( $parameters ) > 0 ) + { + $this->report->reportType = trim( $parameters[1], '"' ); + } + } + + /** + * Adds the part $part to the list of multipart messages. + * + * This method is called automatically by ezcMailMultipartParser + * each time a part is parsed. + * + * @param ezcMailPart $part + */ + public function partDone( ezcMailPart $part ) + { + $this->parts[] = $part; + } + + /** + * Returns the parts parsed for this multipart. + * + * @return ezcMailMultipartReport + */ + public function finishMultipart() + { + if ( isset( $this->parts[0] ) ) + { + $this->report->setReadablePart( $this->parts[0] ); + } + if ( isset( $this->parts[1] ) ) + { + $this->report->setMachinePart( $this->parts[1] ); + } + if ( isset( $this->parts[2] ) ) + { + $this->report->setOriginalPart( $this->parts[2] ); + } + return $this->report; + } +} +?> Property changes on: trunk/Mail/src/parser/parts/multipart_report_parser.php ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/Mail/src/parts/delivery_status.php =================================================================== --- trunk/Mail/src/parts/delivery_status.php 2007-01-19 12:02:40 UTC (rev 4534) +++ trunk/Mail/src/parts/delivery_status.php 2007-01-19 15:03:57 UTC (rev 4535) @@ -0,0 +1,185 @@ +<?php +/** + * File containing the ezcMailDeliveryStatus class + * + * @package Mail + * @version //autogen// + * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + */ + +/** + * Mail part used for sending delivery status message. + * + * Multipart/Report: RFC 3462 [EMAIL PROTECTED] http://tools.ietf.org/html/rfc3462} + * Delivery Status Notifications: RFC 3464 [EMAIL PROTECTED] http://tools.ietf.org/html/rfc3464} + * + * This mail part consists of only headers. The headers are organized into section. + * There is a per-message section ($message), and several per-recipient sections ($recipients). + * + * To access the headers of this part, look at the following example: + * <code> + * // $delivery is an object of type ezcMailDeliveryStatus + * $reportingMta = $delivery->message["Reporting-MTA"]; + * $date = $delivery->message["Arrival-Date"]; + * // get the status received from the first recipient + * $status1 = $delivery->recipients[0]["Status"]; + * // get the status received from the second recipient + * $status2 = $delivery->recipients[1]["Status"]; + * </code> + * + * @property ezcMailHeadersHolder $message + * Holds the per-message headers of the delivery-status message. + * @property ArrayObject(ezcMailHeadersHolder) $recipients + * Holds the recipients of the delivery-status message. + * + * @package Mail + * @version //autogen// + */ +class ezcMailDeliveryStatus extends ezcMailPart +{ + /** + * Holds the properties of this class. + * + * @var array(string=>mixed) + */ + private $properties = array(); + + /** + * Constructs a new DeliveryStatus part. + */ + public function __construct() + { + $this->message = new ezcMailHeadersHolder(); + $this->recipients = new ArrayObject(); + parent::__construct(); + } + + /** + * Sets the property $name to $value. + * + * @throws ezcBasePropertyNotFoundException + * if the property does not exist + * @param string $name + * @param mixed $value + * @ignore + */ + public function __set( $name, $value ) + { + switch ( $name ) + { + case 'message': + case 'recipients': + $this->properties[$name] = $value; + break; + + default: + return parent::__set( $name, $value ); + break; + } + } + + /** + * Returns the property $name. + * + * @throws ezcBasePropertyNotFoundException + * if the property does not exist + * @param string $name + * @return mixed + * @ignore + */ + public function __get( $name ) + { + switch ( $name ) + { + case 'message': + case 'recipients': + return $this->properties[$name]; + break; + + default: + return parent::__get( $name ); + break; + } + } + + /** + * Returns true if the property $name is set, otherwise false. + * + * @param string $name + * @return bool + * @ignore + */ + public function __isset( $name ) + { + switch ( $name ) + { + case 'message': + case 'recipients': + return isset( $this->properties[$name] ); + + default: + return parent::__isset( $name ); + } + } + + /** + * Returns the headers set for this part as a RFC822 compliant string. + * + * This method does not add the required two lines of space + * to separate the headers from the body of the part. + * + * @see setHeader() + * @return string + */ + public function generateHeaders() + { + $this->setHeader( "Content-Type", "message/delivery-status" ); + return parent::generateHeaders(); + } + + /** + * Returns the generated text body of this part as a string. + * + * @return string + */ + public function generateBody() + { + $result = $this->addHeadersSection( $this->message ) . ezcMailTools::lineBreak(); + for ( $i = 0; $i < count( $this->recipients ); $i++ ) + { + $result .= $this->addHeadersSection( $this->recipients[$i] ) . ezcMailTools::lineBreak(); + } + return $result; + } + + /** + * Returns the generated text for a section of the delivery-status part. + * + * @param ezcMailHeadersHolder $headers + * @return string + */ + private function addHeadersSection( ezcMailHeadersHolder $headers ) + { + $result = ""; + foreach ( $headers->getCaseSensitiveArray() as $header => $value ) + { + $result .= $header . ": " . $value . ezcMailTools::lineBreak(); + } + return $result; + } + + /** + * Adds a new recipient to this delivery-status message and returns the index + * of the last added recipient. + * + * @return int + */ + public function createRecipient() + { + $result = count( $this->recipients ); + $this->recipients[$result] = new ezcMailHeadersHolder(); + return $result; + } +} +?> Property changes on: trunk/Mail/src/parts/delivery_status.php ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/Mail/src/parts/multiparts/multipart_report.php =================================================================== --- trunk/Mail/src/parts/multiparts/multipart_report.php 2007-01-19 12:02:40 UTC (rev 4534) +++ trunk/Mail/src/parts/multiparts/multipart_report.php 2007-01-19 15:03:57 UTC (rev 4535) @@ -0,0 +1,232 @@ +<?php +/** + * File containing the ezcMailMultipartReport class + * + * @package Mail + * @version //autogen// + * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + */ + +/** + * Mail part multipart/report used primarily to send delivery status notification messages. + * + * Multipart/Report: RFC 3462 [EMAIL PROTECTED] http://tools.ietf.org/html/rfc3462} + * Delivery Status Notifications: RFC 3464 [EMAIL PROTECTED] http://tools.ietf.org/html/rfc3464} + * + * The subparts of this mail part are according to RFC 3462: + * + * 1. A human readable part. The purpose of this part is to provide an easily understood + * description of the condition(s) that caused the report to be generated. + * Use the methods getReadablePart() and setReadablePart() to work with this part. + * + * 2. A machine parsable body part containing an account of + * the reported message handling event. The purpose of this body part is + * to provide a machine-readable description of the condition(s) that + * caused the report to be generated, along with details not present in + * the first body part that may be useful to human experts. + * Use the methods getMachinePart() and setMachinePart() to work with this part. + * + * 3. Optional. A body part containing the returned message or a + * portion thereof. This information may be useful to aid human experts + * in diagnosing problems. + * Use the methods getOriginalPart() and setOriginalPart() to work with this part. + * + * @property string $reportType + * The report type of the multipart report. Default is "delivery-status". + * + * @package Mail + * @version //autogen// + */ +class ezcMailMultipartReport extends ezcMailMultipart +{ + /** + * Holds the properties of this class. + * + * @var array(string=>mixed) + */ + private $properties = array(); + + /** + * Constructs a new ezcMailMultipartReport. + * + * @param ezcMailPart|array(ezcMailPart) + */ + public function __construct() + { + $args = func_get_args(); + parent::__construct( $args ); + $this->reportType = "delivery-status"; + } + + /** + * Sets the property $name to $value. + * + * @throws ezcBasePropertyNotFoundException + * if the property does not exist + * @param string $name + * @param mixed $value + * @ignore + */ + public function __set( $name, $value ) + { + switch ( $name ) + { + case 'reportType': + $this->properties[$name] = $value; + $this->setHeader( 'Content-Type', 'multipart/' . $this->multipartType() . '; ' . + 'report-type=' . $this->reportType . '; ' . + 'boundary="' . $this->boundary . '"' ); + break; + + default: + return parent::__set( $name, $value ); + break; + } + } + + /** + * Returns the property $name. + * + * @throws ezcBasePropertyNotFoundException + * if the property does not exist + * @param string $name + * @return mixed + * @ignore + */ + public function __get( $name ) + { + switch ( $name ) + { + case 'reportType': + return $this->properties[$name]; + break; + + default: + return parent::__get( $name ); + break; + } + } + + /** + * Returns true if the property $name is set, otherwise false. + * + * @param string $name + * @return bool + * @ignore + */ + public function __isset( $name ) + { + switch ( $name ) + { + case 'reportType': + return isset( $this->properties[$name] ); + + default: + return parent::__isset( $name ); + } + } + + /** + * Appends a part to the list of parts. + * + * @param ezcMailPart $part + */ + public function appendPart( ezcMailPart $part ) + { + $this->parts[] = $part; + } + + /** + * Returns the mail parts associated with this multipart. + * + * @return array(ezcMailPart) + */ + public function getParts() + { + return $this->parts; + } + + /** + * Sets the readable $part of this report multipart. + * + * @param ezcMailPart $part + */ + public function setReadablePart( ezcMailPart $part ) + { + $this->parts[0] = $part; + } + + /** + * Returns the readable part of this multipart or null if there is no such part. + * + * @return ezcMailPart + */ + public function getReadablePart() + { + if ( isset( $this->parts[0] ) ) + { + return $this->parts[0]; + } + return null; + } + + /** + * Sets the machine $part of this report multipart. + * + * @param ezcMailPart $part + */ + public function setMachinePart( ezcMailPart $part ) + { + $this->parts[1] = $part; + } + + /** + * Returns the machine part of this multipart or null if there is no such part. + * + * @return ezcMailPart + */ + public function getMachinePart() + { + if ( isset( $this->parts[1] ) ) + { + return $this->parts[1]; + } + return null; + } + + /** + * Sets the original content $part of this report multipart. + * + * @param ezcMailPart $part + */ + public function setOriginalPart( ezcMailPart $part ) + { + $this->parts[2] = $part; + } + + /** + * Returns the original content part of this multipart or null if there is no such part. + * + * @return ezcMailPart + */ + public function getOriginalPart() + { + if ( isset( $this->parts[2] ) ) + { + return $this->parts[2]; + } + return null; + } + + /** + * Returns "report". + * + * @return string + */ + public function multipartType() + { + return "report"; + } +} +?> Property changes on: trunk/Mail/src/parts/multiparts/multipart_report.php ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/Mail/tests/mail_test.php =================================================================== --- trunk/Mail/tests/mail_test.php 2007-01-19 12:02:40 UTC (rev 4534) +++ trunk/Mail/tests/mail_test.php 2007-01-19 15:03:57 UTC (rev 4535) @@ -8,7 +8,6 @@ * @subpackage Tests */ - /** * @package Mail * @subpackage Tests @@ -263,6 +262,24 @@ // $transport->send( $this->mail ); } + public function testMultipartReport() + { + $mail = new ezcMail(); + $mail->from = new ezcMailAddress( '[EMAIL PROTECTED]', 'Frederik Holljen' ); + $mail->addTo( new ezcMailAddress( '[EMAIL PROTECTED]', 'Frederik Holljen' ) ); + $mail->subject = "Report"; + $mail->subjectCharset = 'iso-8859-1'; + $delivery = new ezcMailDeliveryStatus(); + $delivery->message["Reporting-MTA"] = "dns; www.brssolutions.com"; + $lastRecipient = $delivery->createRecipient(); + $delivery->recipients[$lastRecipient]["Action"] = "failed"; + $mail->body = new ezcMailMultipartReport( + new ezcMailText( "Dette er body ßßæøååå", "iso-8859-1" ), + $delivery, + new ezcMailText( "The content initially sent" ) + ); + } + public function testMessageID1() { $this->mail->from = new ezcMailAddress( '[EMAIL PROTECTED]', 'Frederik Holljen' ); Added: trunk/Mail/tests/parser/data/various/multipart-report =================================================================== --- trunk/Mail/tests/parser/data/various/multipart-report 2007-01-19 12:02:40 UTC (rev 4534) +++ trunk/Mail/tests/parser/data/various/multipart-report 2007-01-19 15:03:57 UTC (rev 4535) @@ -0,0 +1,104 @@ +Return-Path: <> +X-Original-To: [EMAIL PROTECTED] +Delivered-To: [EMAIL PROTECTED] +Received: from punisher.dreamhost.com (punisher.dreamhost.com [66.33.206.109]) + by fractured.dreamservers.com (Postfix) with ESMTP id B84ED80EBE + for <[EMAIL PROTECTED]>; Mon, 17 Jul 2006 12:35:07 -0700 (PDT) +Received: from localhost (localhost [127.0.0.1]) + by punisher.dreamhost.com (Postfix) with ESMTP id 67FEC67392 + for <[EMAIL PROTECTED]>; Mon, 17 Jul 2006 12:35:07 -0700 (PDT) +Received: from punisher.dreamhost.com ([127.0.0.1]) + by localhost (punisher [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 18012-11 for <[EMAIL PROTECTED]>; + Mon, 17 Jul 2006 12:35:07 -0700 (PDT) +Received: from www.brssolutions.com (unknown [216.198.224.130]) + by punisher.dreamhost.com (Postfix) with ESMTP id 0449E67401 + for <[EMAIL PROTECTED]>; Mon, 17 Jul 2006 12:35:06 -0700 (PDT) +Received: from localhost (localhost) + by www.brssolutions.com (8.13.4/8.13.4) id k6HJpREA009057; + Mon, 17 Jul 2006 14:51:27 -0500 +Date: Mon, 17 Jul 2006 14:51:27 -0500 +From: Mail Delivery Subsystem <[EMAIL PROTECTED]> +Message-Id: <[EMAIL PROTECTED]> +To: <[EMAIL PROTECTED]> +MIME-Version: 1.0 +Content-Type: multipart/report; report-type=delivery-status; + boundary="k6HJpREA009057.1153165887/www.brssolutions.com" +Subject: Returned mail: see transcript for details +Auto-Submitted: auto-generated (failure) +X-DH-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at punisher +X-Spam-Status: No, hits=0.1 tagged_above=-999.0 required=999.0 + tests=HTML_50_60, HTML_MESSAGE, UPPERCASE_25_50 +X-Spam-Level: + +This is a MIME-encapsulated message + +--k6HJpREA009057.1153165887/www.brssolutions.com + +The original message was received at Mon, 17 Jul 2006 14:51:25 -0500 +from pool-72-82-7-210.prvdri.east.verizon.net [72.82.7.210] + + ----- The following addresses had permanent fatal errors ----- [EMAIL PROTECTED] + (reason: 550 5.1.1 User unknown) + (expanded from: <[EMAIL PROTECTED]>) + + ----- Transcript of session follows ----- +550 5.1.1 /home/default.hostharbour.com/.forward: line 2: [EMAIL PROTECTED] User unknown + +--k6HJpREA009057.1153165887/www.brssolutions.com +Content-Type: message/delivery-status + +Reporting-MTA: dns; www.brssolutions.com +Received-From-MTA: DNS; pool-72-82-7-210.prvdri.east.verizon.net +Arrival-Date: Mon, 17 Jul 2006 14:51:25 -0500 + +Final-Recipient: RFC822; [EMAIL PROTECTED] +X-Actual-Recipient: RFC822; [EMAIL PROTECTED] +Action: failed +Status: 5.1.1 +Diagnostic-Code: X-Unix; 550 5.1.1 User unknown +Last-Attempt-Date: Mon, 17 Jul 2006 14:51:27 -0500 + +--k6HJpREA009057.1153165887/www.brssolutions.com +Content-Type: message/rfc822 + +Return-Path: <[EMAIL PROTECTED]> +Received: from brssolutions.brssolutions.com (pool-72-82-7-210.prvdri.east.verizon.net [72.82.7.210]) + by www.brssolutions.com (8.13.4/8.13.4) with SMTP id k6HJpLEA008995 + for <[EMAIL PROTECTED]>; Mon, 17 Jul 2006 14:51:25 -0500 +Received: from fltr-in1.mail.dreamhost.com + by pool-72-82-7-210.prvdri.east.verizon.net (Exim 4.05) with ESMTP id F0rmXZIVkPctz + for <[EMAIL PROTECTED]>; Mon, 17 Jul 2006 19:34:51 -0300 +Received: from [69.27.45.184] + by fltr-in1.mail.dreamhost.com with ESMTP (8.9.3/8.9.3) id qFWnVSZMaqHdI + for <[EMAIL PROTECTED]>; Mon, 17 Jul 2006 19:27:07 -0300 +Reply-to: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> +From: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> +Date: Mon, 17 Jul 2006 19:20:60 -0300 +Message-ID: [EMAIL PROTECTED] +To: [EMAIL PROTECTED] +Content-type: text/html; + Charset=Windows-1251 +Subject: Too busy to go back to school? +MIME-Version: 1.0 + +<h1 align="center">Un1versity Degree</h1> +<div @lign="center"><br> + OBTAIN A <acd></acd>PROSPEROUS FUTURE, MONEY-EARNING POWER,<BR>AND THE PRESTIGE THAT COMES + WITH HAVING THE CAREER <acg></acg>POSITION YOU'VE<BR>ALWAYS DREAMED <ace></ace>OF. <acc></acc>DIPLOMA FROM<BR>PRESTIGIOUS + NON-ACCREDITED<BR>UNVERSITIES BASED ON YOUR PRESENT KNOWLEDGE AND PROFESSIONAL + EXPERIENCE.<br> + <acd></acd><i><font size="4"><b><font size="5">If you qualify, no required tests, classes, + books or <act></act>examinations.</font></b></font></i> <font size="5"><b><br> + </b></font><br> + <acv></acv><b><font size="5">Confidentiality Assured<br> + <acg></acg></font></b><br> + <font color="#FF0033" size="+2"><b>1-815-828-2222</b></font><br> + 24 <acc></acc>hours a day, 7 <ach></ach>days a week including Sundays and <acs></acs>Holidays<br> +</div><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>question her about the <ack></ack>Howler, but he might as well <acj></acj>have <acy></acy>interrogated + + + + +--k6HJpREA009057.1153165887/www.brssolutions.com-- Added: trunk/Mail/tests/parser/data/various/multipart-report-multiple-deliveries =================================================================== --- trunk/Mail/tests/parser/data/various/multipart-report-multiple-deliveries 2007-01-19 12:02:40 UTC (rev 4534) +++ trunk/Mail/tests/parser/data/various/multipart-report-multiple-deliveries 2007-01-19 15:03:57 UTC (rev 4535) @@ -0,0 +1,48 @@ +Date: Fri, 8 Jul 1994 09:21:47 -0400 +From: Mail Delivery Subsystem <[EMAIL PROTECTED]> +Subject: Returned mail: User unknown +To: <[EMAIL PROTECTED]> +MIME-Version: 1.0 +Content-Type: multipart/report; report-type=delivery-status; + boundary="JAA13167.773673707/CS.UTK.EDU" + +--JAA13167.773673707/CS.UTK.EDU +content-type: text/plain; charset=us-ascii + + ----- The following addresses had delivery problems ----- +<[EMAIL PROTECTED]> (unrecoverable error) +<[EMAIL PROTECTED]> (unrecoverable error) + +--JAA13167.773673707/CS.UTK.EDU +content-type: message/delivery-status + +Reporting-MTA: dns; cs.utk.edu + +Original-Recipient: rfc822;[EMAIL PROTECTED] +Final-Recipient: rfc822;[EMAIL PROTECTED] +Action: failed +Status: 5.0.0 (permanent failure) +Diagnostic-Code: smtp; 550 '[EMAIL PROTECTED]' is not a +registered gateway user +Remote-MTA: dns; vnet.ibm.com + +Original-Recipient: rfc822;[EMAIL PROTECTED] +Final-Recipient: rfc822;[EMAIL PROTECTED] +Action: delayed +Status: 4.0.0 (hpnjld.njd.jp.com: host name lookup failure) + +Original-Recipient: rfc822;[EMAIL PROTECTED] +Final-Recipient: rfc822;[EMAIL PROTECTED] +Action: failed +Status: 5.0.0 +Diagnostic-Code: smtp; 550 user unknown +Remote-MTA: dns; sdcc13.ucsd.edu + +--JAA13167.773673707/CS.UTK.EDU +content-type: message/rfc822 + +To: [EMAIL PROTECTED] + +[original message goes here] + +--JAA13167.773673707/CS.UTK.EDU-- Modified: trunk/Mail/tests/parser/parser_test.php =================================================================== --- trunk/Mail/tests/parser/parser_test.php 2007-01-19 12:02:40 UTC (rev 4534) +++ trunk/Mail/tests/parser/parser_test.php 2007-01-19 15:03:57 UTC (rev 4535) @@ -1078,5 +1078,64 @@ $this->assertEquals( $expected[$i], get_class( $parts[$i] ) ); } } + + public function testMultipartReport() + { + $parser = new ezcMailParser(); + $set = new SingleFileSet( 'various/multipart-report' ); + $mail = $parser->parseMail( $set ); + $mail = $mail[0]; + $parts = $mail->fetchParts( null, true ); + $expected = array( 'ezcMailText', + 'ezcMailDeliveryStatus', + 'ezcMailText' + ); + $this->assertEquals( 3, count( $parts ) ); + for ( $i = 0; $i < count( $parts ); $i++ ) + { + $this->assertEquals( $expected[$i], get_class( $parts[$i] ) ); + } + $this->assertEquals( "dns; www.brssolutions.com", $parts[1]->message["Reporting-MTA"] ); + $this->assertEquals( "failed", $parts[1]->recipients[0]["Action"] ); + } + + public function testMultipartReportMultipleDeliveries() + { + $parser = new ezcMailParser(); + $set = new SingleFileSet( 'various/multipart-report-multiple-deliveries' ); + $mail = $parser->parseMail( $set ); + $mail = $mail[0]; + $parts = $mail->fetchParts( null, true ); + $expected = array( 'ezcMailText', + 'ezcMailDeliveryStatus', + 'ezcMailText' + ); + $this->assertEquals( 3, count( $parts ) ); + for ( $i = 0; $i < count( $parts ); $i++ ) + { + $this->assertEquals( $expected[$i], get_class( $parts[$i] ) ); + } + $this->assertEquals( 3, count( $parts[1]->recipients ) ); + $this->assertEquals( "dns; cs.utk.edu", $parts[1]->message["Reporting-MTA"] ); + $this->assertEquals( "5.0.0 (permanent failure)", $parts[1]->recipients[0]["Status"] ); + $this->assertEquals( "delayed", $parts[1]->recipients[1]["Action"] ); + $this->assertEquals( "smtp; 550 user unknown", $parts[1]->recipients[2]["Diagnostic-Code"] ); + } + + public function testMultipartReportParts() + { + $parser = new ezcMailParser(); + $set = new SingleFileSet( 'various/multipart-report-multiple-deliveries' ); + $mail = $parser->parseMail( $set ); + $report = $mail[0]->body; + $this->assertEquals( "ezcMailMultipartReport", get_class( $report ) ); + $this->assertEquals( true, strpos( $report->getReadablePart()->text, "[EMAIL PROTECTED]" ) ); + $delivery = $report->getMachinePart(); + $this->assertEquals( "dns; cs.utk.edu", $delivery->message["Reporting-MTA"] ); + $this->assertEquals( "rfc822;[EMAIL PROTECTED]", $delivery->recipients[0]["Final-Recipient"] ); + $this->assertEquals( null, $delivery->recipients[0]["no such header"] ); + $original = $report->getOriginalPart(); + $this->assertEquals( "[original message goes here]", trim( $original->mail->body->text ) ); + } } ?> Modified: trunk/Mail/tests/parts/multipart_test.php =================================================================== --- trunk/Mail/tests/parts/multipart_test.php 2007-01-19 12:02:40 UTC (rev 4534) +++ trunk/Mail/tests/parts/multipart_test.php 2007-01-19 15:03:57 UTC (rev 4535) @@ -156,13 +156,75 @@ $this->assertEquals( 1, count( $part->getRelatedParts() ) ); } + public function testMultipartReportFetchParts() + { + $mail = new ezcMail(); + $mail->from = new ezcMailAddress( '[EMAIL PROTECTED]', 'Frederik Holljen' ); + $mail->addTo( new ezcMailAddress( '[EMAIL PROTECTED]', 'Frederik Holljen' ) ); + $mail->subject = "Report"; + $mail->subjectCharset = 'iso-8859-1'; + $delivery = new ezcMailDeliveryStatus(); + $delivery->message["Reporting-MTA"] = "dns; www.brssolutions.com"; + $lastRecipient = $delivery->createRecipient(); + $delivery->recipients[$lastRecipient]["Action"] = "failed"; + $mail->body = new ezcMailMultipartReport( + new ezcMailText( "Dette er body ÃÃæøååå", "iso-8859-1" ), + $delivery, + new ezcMailText( "The content initially sent" ) + ); + $this->assertEquals( "delivery-status", $mail->body->reportType ); + $msg = $mail->generate(); + $set = new ezcMailVariableSet( $msg ); + $parser = new ezcMailParser(); + $mail = $parser->parseMail( $set ); + $mail = $mail[0]; + $parts = $mail->fetchParts( null, true ); + $expected = array( 'ezcMailText', + 'ezcMailDeliveryStatus', + 'ezcMailText' + ); + $this->assertEquals( 3, count( $parts ) ); + for ( $i = 0; $i < count( $parts ); $i++ ) + { + $this->assertEquals( $expected[$i], get_class( $parts[$i] ) ); + } + } + + public function testMultipartReportEmpty() + { + $report = new ezcMailMultipartReport(); + $this->assertEquals( null, $report->getReadablePart() ); + $this->assertEquals( null, $report->getMachinePart() ); + $this->assertEquals( null, $report->getOriginalPart() ); + } + public function testIsSet() { $part = new ezcMailMultipartRelated(); $this->assertEquals( true, isset( $part->boundary ) ); $this->assertEquals( false, isset( $part->no_such_property ) ); + + $part = new ezcMailMultipartReport(); + $this->assertEquals( true, isset( $part->reportType ) ); + $this->assertEquals( false, isset( $part->no_such_property ) ); } + public function testDeliveryStatusProperties() + { + $part = new ezcMailDeliveryStatus(); + $this->assertEquals( true, isset( $part->message ) ); + $this->assertEquals( true, isset( $part->recipients ) ); + $this->assertEquals( false, isset( $part->no_such_property ) ); + + try + { + $part->no_such_property = ""; + } + catch ( ezcBasePropertyNotFoundException $e ) + { + } + } + public static function suite() { return new PHPUnit_Framework_TestSuite( "ezcMailMultipartTest" ); -- svn-components mailing list svn-components@lists.ez.no http://lists.ez.no/mailman/listinfo/svn-components