Apache Zeta Components Manual :: File Source for mail.php
Source for file mail.php
Documentation is available at mail.php
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @version //autogentag//
* Request parser that uses an e-mail message to populate an ezcMvcRequest object.
* @version //autogentag//
* Uses stdin, or the provided data in $mailMessage.
* @param string $mailMessage
if ( $mailMessage ===
null )
$mail =
$parser->parseMail( $set );
if ( count( $mail ) ==
0 )
* Processes the standard headers that are not subdivided into other structs.
$req->date = isset
( $mail->timestamp )
?
new DateTime( "@{$mail->timestamp}" )
$email =
$mail->to[0]->email;
$req->requestId =
$req->host .
'/' .
$req->uri;
$req->referrer = isset
( $mail->headers['In-Reply-To'] )
?
trim( $mail->headers['In-Reply-To'], '<>' )
:
trim( substr( $mail->headers['References'], 0, strpos( $mail->headers['References'], ' ' ) -
1 ), '<>' );
// As variables we'll add the from name/address and subject
'fromAddress' =>
$mail->from->email,
'fromName' =>
$mail->from->name,
'subject' =>
$mail->subject,
// For the body, we take the first ezcMailText part we can find. If
// that's not enough, the rest can be accesible through raw.
$context->filter =
array( 'ezcMailText' );
$mail->walkParts( $context, $mail );
* Sets the request body to the text of the $mailText if the body is empty.
* @param ezcMailPartWalkContext $context
* @param ezcMailText $mailText
public function getBody( ezcMailPartWalkContext $context, ezcMailText $mailText )
$this->request->body =
$mailText->text;
* Does really nothing, as Mail doesn't have those bits.
* Processes the User Agent header into the ezcMvcRequestUserAgent struct.
$agent->agent = isset
( $mail->headers['User-Agent'] )
?
$mail->headers['User-Agent']
* Processes file attachments.
$context->filter =
array( 'ezcMailFile' );
$mail->walkParts( $context, $mail );
* Adds a found attachment to the request structure.
* @param ezcMailPartWalkContext $context
* @param ezcMailFile $mailFile
public function addFile( ezcMailPartWalkContext $context, ezcMailFile $mailFile )
$file->mimeType =
$mailFile->contentType .
'/' .
$mailFile->mimeType;
$file->name =
$mailFile->contentDisposition->displayFileName;
$file->size =
$mailFile->size;
$file->tmpPath =
$mailFile->fileName;