udarajay / mep
Simply parse e-mails and attachments
v0.4
2018-09-12 20:54 UTC
Requires
- php: ^7.1.3
Requires (Dev)
- phpunit/phpunit: ^5.7
This package is auto-updated.
Last update: 2024-12-25 14:22:01 UTC
README
A minimal PHP library for parsing RAW emails (rfc2822).
Motivation
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.
Installation
The recommended way to install MEP is through Composer:
composer require udarajay/mep
Usage
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();
Todo
- Parse headers with fallback
- Parse HTML body in fragments with fallback to Text
- Generate raw email (threaded) messages for Gmail