Minimal Email Parser (MEP)
A minimal PHP library for parsing RAW emails (rfc2822).
Creating the simplest possible parser for taking a raw email and converting it to a simple decoded object with easily accessible headers and body parts (threaded emails) that can be rendered beautifully.
The recommended way to install MEP is through Composer:
composer require udarajay/mep
require 'vendor/autoload.php';
use UJ\MEP\EmailParser;
// Init by passing in a raw email as a string
$parser = EmailParser::parse($raw);
// Access un-parsed parts
$parser->getRaw();
$parser->getBody();
$parser->getHeaders();
// Parsed header content
$parser->getMessageId();
$parser->getFrom();
$parser->getTo();
$parser->getSubject();
$parser->getDeliveredTo();
$parser->getContentType();
$parser->getContentLanguage();
$parser->getMimeVersion();
// Parsed fragments (Message parts)
$fragments = $parser->getFragments();
- Parse headers with fallback
- Parse HTML body in fragments with fallback to Text
- Generate raw email (threaded) messages for Gmail