Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/udarajay/mep
Simply parse e-mails and attachments
https://github.com/udarajay/mep
email email-parsing
Last synced: about 2 months ago
JSON representation
Simply parse e-mails and attachments
- Host: GitHub
- URL: https://github.com/udarajay/mep
- Owner: UdaraJay
- License: mit
- Created: 2018-08-28T05:48:21.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-09-24T23:10:41.000Z (over 6 years ago)
- Last Synced: 2024-11-14T22:43:34.342Z (2 months ago)
- Topics: email, email-parsing
- Language: PHP
- Size: 522 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# [Minimal Email Parser](https://github.com/UdaraJay/MEP) (MEP)
[![Build Status](https://travis-ci.org/UdaraJay/MEP.svg?branch=master)](https://travis-ci.org/UdaraJay/MEP)
[![Latest Stable Version](https://poser.pugx.org/udarajay/mep/version)](https://packagist.org/packages/udarajay/mep)
[![Total Downloads](https://poser.pugx.org/udarajay/mep/downloads)](https://packagist.org/packages/udarajay/mep)
[![License](https://poser.pugx.org/udarajay/mep/license)](https://packagist.org/packages/udarajay/mep)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](https://getcomposer.org/):
```
composer require udarajay/mep
```## Usage
```php
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
- [x] Parse headers with fallback
- [ ] Parse HTML body in fragments with fallback to Text
- [ ] Generate raw email (threaded) messages for Gmail