


Supports all of RFC-5322, RFC-2822 and RFC-822, and tries to be as forgivingĪs possible for incorrectly formatted messages.

No need to worryĪbout whether the content is base64 encoded and using WINDOWS-1256 charsetĮncoding (so long as mb_* or iconv* support the charset, or I’ve identified Handles content decoding and charset conversion for you.Users rely on regex patterns to decode parts of a header, and end up ignoring No need to worry about theįormat a header is in, if it’s RFC2047 or RFC2231, contains nested comments,Įmail lists, multiple lines, or combinations thereof. Handles header decoding/charset/formats for you.There are numerous advantages over other libraries: It does not use PHP’s imap* functions or the pecl mailparse There’s no need to worry about the Content-Transfer-Encoding, or how the name inĪn email address is encoded, or what charset was used.Īnd, unlike most other available email parsing libraries, MailMimeParser is its Use ZBateson\MailMimeParser\Message $message = Message :: parse ( $handleOrStreamOrString, true ) $subject = $message -> getHeaderValue ( 'Subject' ) $text = $message -> getTextContent () $html = $message -> getHtmlContent () $from = $message -> getHeader ( 'From' ) $fromName = $from -> getName () $fromEmail = $from -> getEmail () $to = $message -> getHeader ( 'To' ) // first email address can be accessed directly $firstToName = $to -> getName () $firstToEmail = $to -> getEmail () foreach ( $to -> getAllAddresses () as $addr ) $attachment = $message -> getAttachmentPart ( 0 ) $fname = $attachment -> getFilename () $stream = $attachment -> getContentStream () $attachment -> saveContent ( 'destination-file.ext' )
