PHPackages                             mfacious/email - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. mfacious/email

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

mfacious/email
==============

Faster MIME Mail Parser could be used to parse emails in MIME format.

0364PHPCI failing

Since Sep 18Pushed 6y ago1 watchersCompare

[ Source](https://github.com/mfacious/email)[ Packagist](https://packagist.org/packages/mfacious/email)[ RSS](/packages/mfacious-email/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Faster MIME Mail Parser
=======================

[](#faster-mime-mail-parser)

Faster MIME Mail Parser could be used to parse emails in MIME format.

Usage
=====

[](#usage)

Basic usage is the following:

```
$file = fopen('path/to/file.eml', 'r');
$message = \bashkarev\email\Parser::email($file);

$message->textHtml();

$message->getParts();
$message->getAttachments();
```

Settings
--------

[](#settings)

There are settings available.

- `charset` - character set to use. Should be specified in uppercase only. Default is `UTF-8`.

    ```
    \bashkarev\email\Parser::$charset = "WINDOWS-1251";
    ```
- `buffer` - read buffer size in bytes. Default is `500000`.

    ```
    \bashkarev\email\Parser::$buffer = 4096;
    ```

Attachments
-----------

[](#attachments)

There is attachments parsing support.

### Saving attachments to files

[](#saving-attachments-to-files)

Saving to files could be done as follows:

```
$file = fopen('path/to/file.eml', 'rb');
$message = \bashkarev\email\Parser::email($file);
foreach ($message->getAttachments() as $attachment) {
    $attachment->save('dir/' . $attachment->getFileName('undefined'));
}
```

### Streaming attachment to output

[](#streaming-attachment-to-output)

In order to stream attachment to output directly you need to do the following:

```
$file = fopen('path/to/file.eml', 'rb');
$message = \bashkarev\email\Parser::email($file);
$attachment = $message->getAttachments()[0];
header("Content-Type: {$attachment->getMimeType()};");
header("Content-Disposition: attachment; filename=\"{$attachment->getFileName('undefined')}\"");
$attachment->getStream()->copy(fopen('php://output', 'c'));
```

message/partial
---------------

[](#messagepartial)

```
$block = \bashkarev\email\Parser::email([
    fopen('path/to/part.1.eml', 'rb'),
    fopen('path/to/part.2.eml', 'rb'),
]);
$block->getMessage();
```

message/rfc822
--------------

[](#messagerfc822)

```
$file = fopen('path/to/file.eml', 'rb');
$container = \bashkarev\email\Parser::email($file);
$message = $container->getAttachments()[0]->getMessage();
```

message/feedback-report
-----------------------

[](#messagefeedback-report)

```
$file = fopen('path/to/file.eml', 'rb');
$container = \bashkarev\email\Parser::email($file);
foreach ($container->getAttachments() as $attachment) {
    if ($attachment->getMimeType() === 'message/feedback-report') {
        /**
         * @var \bashkarev\email\messages\Feedback $feedback
         */
        $feedback = $attachment->getMessage();
        $feedback->getType(); // Feedback::TYPE_ABUSE ...
    }
}
```

message/external-body
---------------------

[](#messageexternal-body)

Supported types: url, local-file, ftp.

### FTP auth

[](#ftp-auth)

```
$file = fopen('path/to/file.eml', 'rb');
$container = \bashkarev\email\Parser::email($file);
foreach ($container->getAttachments() as $attachment) {
    if ($attachment->getStream() instanceof \bashkarev\email\transports\Ftp) {
        /**
         * @var \bashkarev\email\transports\Ftp $transport
         */
        $transport = $attachment->getStream();
        $transport->username = 'username';
        $transport->password = '******';
        $attachment->save('dir/' . $attachment->getFileName('undefined'));
    }
}
```

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4935188?v=4)[mfacious](/maintainers/mfacious)[@mfacious](https://github.com/mfacious)

### Embed Badge

![Health badge](/badges/mfacious-email/health.svg)

```
[![Health](https://phpackages.com/badges/mfacious-email/health.svg)](https://phpackages.com/packages/mfacious-email)
```

###  Alternatives

[mck89/peast

Peast is PHP library that generates AST for JavaScript code

19037.7M41](/packages/mck89-peast)[sauladam/shipment-tracker

Parses tracking information for several carriers, like UPS, USPS, DHL and GLS by simply scraping the data. No need for any kind of API access.

9642.0k](/packages/sauladam-shipment-tracker)[jstewmc/rtf

Read and write Rich Text Format (RTF) documents with PHP

46143.1k6](/packages/jstewmc-rtf)[moonshine/layouts-field

Field for repeating groups of fields for MoonShine

107.9k](/packages/moonshine-layouts-field)[tcds-io/php-jackson

A lightweight, flexible object serializer for PHP, inspired by FasterXML/jackson

112.9k10](/packages/tcds-io-php-jackson)

PHPackages © 2026

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