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. mfacious/email

ActiveLibrary

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

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

0361PHPCI 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 3d 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 14% 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://www.gravatar.com/avatar/3f36fa2f4aa4117344b6e02097dc22b321d057f00358b50410a4350b0df89446?d=identicon)[mfacious](/maintainers/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)
```

PHPackages © 2026

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