/** * 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; }
/** * 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; }
/** * 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; }
/** * Returns an array of ezcMail objects parsed from the mail set $set. * * You can optionally use ezcMailParserOptions to provide an alternate class * name which will be instantiated instead of ezcMail, if you need to extend * ezcMail. * * Example: * <code> * $options = new ezcMailParserOptions(); * $options->mailClass = 'MyMailClass'; * * $parser = new ezcMailParser( $options ); * // if you want to use MyMailClass which extends ezcMail * </code> * * @apichange Remove second parameter * * @throws ezcBaseFileNotFoundException * if a neccessary temporary file could not be openened. * @param ezcMailParserSet $set * @param string $class Deprecated. Use $mailClass in ezcMailParserOptions class instead. * @return array(ezcMail) */ public function parseMail(ezcMailParserSet $set, $class = null) { $mail = array(); if (!$set->hasData()) { return $mail; } if ($class === null) { $class = $this->options->mailClass; } do { $this->partParser = new ezcMailRfc822Parser(); $data = ""; $size = 0; while (($data = $set->getNextLine()) !== null) { $this->partParser->parseBody($data); $size += strlen($data); } $part = $this->partParser->finish($class); $part->size = $size; $mail[] = $part; } while ($set->nextMail()); return $mail; }