headers = new ezcMailHeadersHolder(); } /** * Parses the body of an rfc 2822 message. * * @throws ezcBaseFileNotFoundException if a neccessary temporary file could not be openened. * @param string $line * @return void */ public function parseBody( $origLine ) { $line = rtrim( $origLine, "\r\n" ); if ( $this->parserState == self::PARSE_STATE_HEADERS && $line == '' ) { $this->parserState = self::PARSE_STATE_BODY; // clean up headers for the part // the rest of the headers should be set on the mail object. $headers = new ezcMailHeadersHolder(); $headers['Content-Type'] = $this->headers['Content-Type']; if ( isset( $this->headers['Content-Transfer-Encoding'] ) ) { $headers['Content-Transfer-Encoding'] = $this->headers['Content-Transfer-Encoding']; } if ( isset( $this->headers['Content-Disposition'] ) ) { $headers['Content-Disposition'] = $this->headers['Content-Disposition']; } // get the correct body type $this->bodyParser = self::createPartParserForHeaders( $headers ); } else if ( $this->parserState == self::PARSE_STATE_HEADERS ) { $this->parseHeader( $line, $this->headers ); } else // we are parsing headers { $this->bodyParser->parseBody( $origLine ); } } /** * Returns an ezcMail corresponding to the parsed message. * * @return ezcMail */ public function finish() { $mail = new ezcMail(); $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->cc = 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']; } if ( $this->bodyParser !== null ) { $mail->body = $this->bodyParser->finish(); } return $mail; } } ?>