/** * Returns a ezcMailRfc822Digest with the digested mail in it. * * @return ezcMailRfc822Digest */ public function finish() { $digest = new ezcMailRfc822Digest($this->mailParser->finish()); ezcMailPartParser::parsePartHeaders($this->headers, $digest); $digest->size = $this->size; return $digest; }
/** * Returns the ezcMailText part corresponding to the parsed message. * * @return ezcMailText */ public function finish() { $charset = "us-ascii"; // RFC 2822 default if (isset($this->headers['Content-Type'])) { preg_match('/\\s*charset\\s?=\\s?"?([^;"\\s]*);?/', $this->headers['Content-Type'], $parameters); if (count($parameters) > 0) { $charset = strtolower(trim($parameters[1], '"')); } } $encoding = strtolower($this->headers['Content-Transfer-Encoding']); if ($encoding == ezcMail::QUOTED_PRINTABLE) { $this->text = quoted_printable_decode($this->text); } else { if ($encoding == ezcMail::BASE64) { $this->text = base64_decode($this->text); } } $this->text = ezcMailCharsetConverter::convertToUTF8($this->text, $charset); $part = new ezcMailText($this->text, 'utf-8', ezcMail::EIGHT_BIT, $charset); $part->subType = $this->subType; $part->setHeaders($this->headers->getCaseSensitiveArray()); ezcMailPartParser::parsePartHeaders($this->headers, $part); $part->size = strlen($this->text); return $part; }
/** * Return the result of the parsed file part. * * This method is called automatically by the parent part. * * @return ezcMailFile */ public function finish() { fclose($this->fp); $this->fp = null; // FIXME: DIRTY PGP HACK // When we have PGP support these lines should be removed. They are here now to hide // PGP parts since they will show up as file attachments if not. if ($this->mainType == "application" && ($this->subType == 'pgp-signature' || $this->subType == 'pgp-keys' || $this->subType == 'pgp-encrypted')) { return null; } // END DIRTY PGP HACK $filePart = new self::$fileClass($this->fileName); // set content type $filePart->setHeaders($this->headers->getCaseSensitiveArray()); ezcMailPartParser::parsePartHeaders($this->headers, $filePart); switch (strtolower($this->mainType)) { case 'image': $filePart->contentType = ezcMailFile::CONTENT_TYPE_IMAGE; break; case 'audio': $filePart->contentType = ezcMailFile::CONTENT_TYPE_AUDIO; break; case 'video': $filePart->contentType = ezcMailFile::CONTENT_TYPE_VIDEO; break; case 'application': $filePart->contentType = ezcMailFile::CONTENT_TYPE_APPLICATION; break; } // set mime type $filePart->mimeType = $this->subType; // set inline disposition mode if set. $matches = array(); if (preg_match('/^\\s*inline;?/i', $this->headers['Content-Disposition'], $matches)) { $filePart->dispositionType = ezcMailFile::DISPLAY_INLINE; } if (preg_match('/^\\s*attachment;?/i', $this->headers['Content-Disposition'], $matches)) { $filePart->dispositionType = ezcMailFile::DISPLAY_ATTACHMENT; } $filePart->size = filesize($this->fileName); return $filePart; }
/** * Returns an ezcMail corresponding to the parsed message. * You can specify an alternate class using the $class parameter, if you * extended ezcMail. * * @param string $class Class to instanciate instead of ezcMail. * @return ezcMail */ public function finish($class = "ezcMail") { $mail = new $class(); $mail->setHeaders($this->headers->getCaseSensitiveArray()); ezcMailPartParser::parsePartHeaders($this->headers, $mail); // from if (isset($this->headers['From'])) { $mail->from = ezcMailTools::parseEmailAddress($this->headers['From']); } // to if (isset($this->headers['To'])) { $mail->to = ezcMailTools::parseEmailAddresses($this->headers['To']); } // cc if (isset($this->headers['Cc'])) { $mail->cc = ezcMailTools::parseEmailAddresses($this->headers['Cc']); } // bcc if (isset($this->headers['Bcc'])) { $mail->bcc = ezcMailTools::parseEmailAddresses($this->headers['Bcc']); } // subject if (isset($this->headers['Subject'])) { $mail->subject = ezcMailTools::mimeDecode($this->headers['Subject']); $mail->subjectCharset = 'utf-8'; } // message ID if (isset($this->headers['Message-Id'])) { $mail->messageID = $this->headers['Message-Id']; } // Return-Path if (isset($this->headers['Return-Path'])) { $mail->returnPath = ezcMailTools::parseEmailAddress($this->headers['Return-Path']); } if ($this->bodyParser !== null) { $mail->body = $this->bodyParser->finish(); } return $mail; }
/** * Completes the parsing of the multipart and returns the corresponding part. * * This method should not be overriden. Use finishMultipart() instead. * * @return ezcMailMultipart */ public function finish() { if ($this->parserState != self::PARSE_STATE_POST_LAST) { // this should never happen // let's give the last parser a chance to clean up after himself if ($this->currentPartParser !== null) { $part = $this->currentPartParser->finish(); $this->partDone($part); $this->currentPartParser = null; } } $multipart = $this->finishMultipart(); ezcMailPartParser::parsePartHeaders($this->headers, $multipart); $multipart->boundary = $this->boundary; return $multipart; }