PHPackages                             mathsgod/eml2html - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. mathsgod/eml2html

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mathsgod/eml2html
=================

Convert EML files to self-contained HTML with base64-embedded inline images

v1.0.0(1mo ago)01MITPHPPHP &gt;=8.0

Since Apr 15Pushed 1mo agoCompare

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

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

eml2html-php
============

[](#eml2html-php)

A PHP library to convert EML files into self-contained HTML, with all inline images embedded as base64 data URIs.

Requirements
------------

[](#requirements)

- PHP 8.0+
- [`ext-mailparse`](https://www.php.net/manual/en/book.mailparse.php) (`pecl install mailparse`)

Installation
------------

[](#installation)

```
composer require mathsgod/eml2html
```

Usage
-----

[](#usage)

### Convert from a file

[](#convert-from-a-file)

```
use Eml2Html\Converter;

$converter = new Converter();
$html = $converter->convertFile('/path/to/email.eml');

file_put_contents('output.html', $html);
```

### Convert from a string

[](#convert-from-a-string)

```
use Eml2Html\Converter;

$converter = new Converter();
$eml = file_get_contents('/path/to/email.eml');
$html = $converter->convertString($eml);
```

How it works
------------

[](#how-it-works)

1. Parses the EML file using [`php-mime-mail-parser`](https://github.com/php-mime-mail-parser/php-mime-mail-parser).
2. Extracts the HTML body (Quoted-Printable and charset decoding handled automatically).
3. Collects all inline attachments and maps each `Content-ID` to a base64 data URI.
4. Replaces every `cid:` reference in the HTML (including the `cid:` bracketed variant emitted by Microsoft Word/Outlook) with the corresponding data URI, producing a fully self-contained HTML file.

API
---

[](#api)

### `Converter::convertFile(string $path): string`

[](#converterconvertfilestring-path-string)

Reads the EML file at `$path` and returns self-contained HTML.
Throws `\InvalidArgumentException` if the file cannot be read.

### `Converter::convertString(string $eml): string`

[](#converterconvertstringstring-eml-string)

Accepts raw EML content as a string and returns self-contained HTML.

License
-------

[](#license)

MIT

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance89

Actively maintained with recent releases

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

55d ago

### Community

Maintainers

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

---

Top Contributors

[![mathsgod](https://avatars.githubusercontent.com/u/18732337?v=4)](https://github.com/mathsgod "mathsgod (5 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mathsgod-eml2html/health.svg)

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

###  Alternatives

[phing/phing

PHing Is Not GNU make; it's a PHP project build system or build tool based on Apache Ant.

1.2k22.2M900](/packages/phing-phing)[abuseio/abuseio

Open Source abusemanagement tool

2281.5k](/packages/abuseio-abuseio)[mikopbx/core

Free PBX system for SMB based on Asterisk

5451.4k](/packages/mikopbx-core)

PHPackages © 2026

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