PHPackages                             opcodesio/mail-parser - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. opcodesio/mail-parser

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

opcodesio/mail-parser
=====================

Parse emails without the mailparse extension

v0.2.3(3mo ago)228.1M↓27.1%3[2 issues](https://github.com/opcodesio/mail-parser/issues)[1 PRs](https://github.com/opcodesio/mail-parser/pulls)6MITPHPPHP ^8.0

Since Aug 25Pushed 3mo ago3 watchersCompare

[ Source](https://github.com/opcodesio/mail-parser)[ Packagist](https://packagist.org/packages/opcodesio/mail-parser)[ RSS](/packages/opcodesio-mail-parser/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (10)Dependencies (4)Versions (18)Used By (6)

Mail Parser for PHP
Simple, fast, no extensions required
========================================================

[](#mail-parser-for-phpsimple-fast-no-extensions-required)

 [Features](#features) | [Installation](#installation) | [Credits](#credits)

[![Packagist](https://camo.githubusercontent.com/3868ca9784c4c9a5ff6d842504f0e6097d6f5a633265424c2049655da9002081/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f70636f646573696f2f6d61696c2d7061727365722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/opcodesio/mail-parser)[![Packagist](https://camo.githubusercontent.com/a632fdd5a82206f1e377f52b38a1d09a36c20b3ec2c043086b96f014eb2798b2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6f70636f646573696f2f6d61696c2d7061727365722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/opcodesio/mail-parser)[![PHP from Packagist](https://camo.githubusercontent.com/4c282e0e37dd532a21ee796fe6bf6ee089f4fc47eb9dce4c383f35f204ed3e71/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6f70636f646573696f2f6d61696c2d7061727365722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/opcodesio/mail-parser)

Features
--------

[](#features)

[OPcodes's](https://www.opcodes.io/) **Mail Parser** has a very simple API to parse emails and their MIME contents. Unlike many other parsers out there, this package does not require the [mailparse](https://www.php.net/manual/en/book.mailparse.php) PHP extension.

Has not been fully tested against RFC 5322.

Get Started
-----------

[](#get-started)

### Requirements

[](#requirements)

- **PHP 8.0+**

### Installation

[](#installation)

To install the package via composer, Run:

```
composer require opcodesio/mail-parser
```

### Usage

[](#usage)

```
use Opcodes\MailParser\Message;

// Parse a message from a string
$message = Message::fromString('...');
// Or from a file location (accessible with file_get_contents())
$message = Message::fromFile('/path/to/email.eml');

$message->getHeaders();                 // get all headers
$message->getHeader('Content-Type');    // 'multipart/mixed; boundary="----=_Part_1_1234567890"'
$message->getFrom();                    // 'Arunas
$message->getTo();                      // 'John Doe
$message->getSubject();                 // 'Subject line'
$message->getDate();                    // `Date:` header as DateTime object
$message->getSize();                    // Email size in bytes

$message->getParts();       // array of \Opcodes\MailParser\MessagePart, which can be html parts, text parts, attachments, etc.
$message->getHtmlPart();    // \Opcodes\MailParser\MessagePart containing the HTML body
$message->getTextPart();    // \Opcodes\MailParser\MessagePart containing the Text body
$message->getAttachments(); // array of \Opcodes\MailParser\MessagePart that represent attachments

$messagePart = $message->getParts()[0];

$messagePart->getHeaders();                 // array of all headers for this message part
$messagePart->getHeader('Content-Type');    // value of a particular header
$messagePart->getContentType();             // 'text/html; charset="utf-8"'
$messagePart->getContent();                 // '....'
$messagePart->getSize();                    // 312
$messagePart->getFilename();                // name of the file, in case this is an attachment part
```

Contributing
------------

[](#contributing)

A guide for contributing is in progress...

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Arunas Skirius](https://github.com/arukompas)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

53

—

FairBetter than 96% of packages

Maintenance79

Regular maintenance activity

Popularity55

Moderate usage in the ecosystem

Community20

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~61 days

Recently: every ~208 days

Total

16

Last Release

101d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/952e4089f2eed5313b942cd03434f2d8ab019f7a41417704c72fc78efe46e0a2?d=identicon)[arukomp](/maintainers/arukomp)

---

Top Contributors

[![arukompas](https://avatars.githubusercontent.com/u/8697942?v=4)](https://github.com/arukompas "arukompas (19 commits)")[![ThomasLandauer](https://avatars.githubusercontent.com/u/1054469?v=4)](https://github.com/ThomasLandauer "ThomasLandauer (2 commits)")

---

Tags

phpmailemailarukompasopcodesioemail parser

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/opcodesio-mail-parser/health.svg)

```
[![Health](https://phpackages.com/badges/opcodesio-mail-parser/health.svg)](https://phpackages.com/packages/opcodesio-mail-parser)
```

###  Alternatives

[railsware/mailtrap-php

The Mailtrap SDK provides methods for all API functions.

58879.6k](/packages/railsware-mailtrap-php)[henrique-borba/php-sieve-manager

A modern (started in 2022) PHP library for the ManageSieve protocol (RFC5804) to create/edit Sieve scripts (RFC5228). Used by Cypht Webmail.

28137.9k3](/packages/henrique-borba-php-sieve-manager)[benhall14/php-imap-reader

A PHP class that makes working with IMAP in PHP simple.

3518.7k](/packages/benhall14-php-imap-reader)[juanparati/brevosuite

Complete Brevo integration with Laravel

1013.2k](/packages/juanparati-brevosuite)[beebmx/kirby-courier

Courier offers a convenient and painless solution for creating emails tailored for your Kirby website.

403.6k2](/packages/beebmx-kirby-courier)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
