0 ) { $mainType = strtolower( $matches[0][1] ); $subType = strtolower( $matches[0][2] ); } } $bodyParser = null; // create the correct type parser for this the detected type of part switch ( $mainType ) { /* RFC 2045 defined types */ case 'image': case 'audio': case 'video': case 'application': $bodyParser = new ezcMailFileParser( $mainType, $subType, $headers ); break; case 'message': $bodyParser = new ezcMailRfc822DigestParser( $headers ); break; case 'text': $bodyParser = new ezcMailTextParser( $subType, $headers ); break; case 'multipart': switch ( $subType ) { case 'mixed': $bodyParser = new ezcMailMultipartMixedParser( $headers ); break; case 'alternative': $bodyParser = new ezcMailMultipartAlternativeParser( $headers ); break; case 'related': $bodyParser = new ezcMailMultipartRelatedParser( $headers ); break; case 'digest': $bodyParser = new ezcMailMultipartDigestParser( $headers ); break; default: $bodyParser = new ezcMailMultipartMixedParser( $headers ); break; } break; /* extensions */ default: // we treat the body as text if no main content type is set // or if it is unknown $bodyParser = new ezcMailTextParser( $headers ); break; } return $bodyParser; } /** * Parses the header given by $line and adds it to $this->headers. * * This method is usually used to parse the headers for a subpart. The * only exception is RFC822 parts since you know the type in advance. * * @todo deal with headers that are listed several times * @param string $line * @param ezcMailHeadersHolder $headers * @return void */ protected function parseHeader( $line, ezcMailHeadersHolder $headers ) { $matches = array(); preg_match_all( "/^([\w-_]*): (.*)/", $line, $matches, PREG_SET_ORDER ); if ( count( $matches ) > 0 ) { $headers[$matches[0][1]] = trim( $matches[0][2] ); $this->lastParsedHeader = $matches[0][1]; } else if ( $this->lastParsedHeader !== null ) // take care of folding { $headers[$this->lastParsedHeader] .= $line; } // else -invalid syntax, this should never happen. } } ?>