headers = $headers; $this->section = 0; $this->part = new ezcMailDeliveryStatus(); $this->size = 0; } /** * Parses each line of the mail part. * * @param string $line */ public function parseBody( $line ) { $this->parseHeader( $line, $this->headers ); $this->size += strlen( $line ); } /** * Parses the header given by $line. * * @param string $line * @param ezcMailHeadersHolder $headers */ protected function parseHeader( $line, ezcMailHeadersHolder $headers ) { $matches = array(); preg_match_all( "/^([\w-_]*):\s?(.*)/", $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() $this->part->size = $this->size; return $this->part; } } ?>