Skip to content

UdaraJay/MEP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Latest Stable Version Total Downloads License

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

About

Simply parse e-mails and attachments

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages