PHPackages                             divineomega/email-structure-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. divineomega/email-structure-parser

Abandoned → [jord-jd/email-structure-parser](/?search=jord-jd%2Femail-structure-parser)Library[Mail &amp; Notifications](/categories/mail)

divineomega/email-structure-parser
==================================

Email Structure Parser

v4.0.0(2mo ago)12.1k1LGPL-3.0-onlyPHP

Since Aug 14Pushed 2mo agoCompare

[ Source](https://github.com/Jord-JD/email-structure-parser)[ Packagist](https://packagist.org/packages/divineomega/email-structure-parser)[ GitHub Sponsors](https://github.com/DivineOmega)[ RSS](/packages/divineomega-email-structure-parser/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (6)DependenciesVersions (7)Used By (0)

Email Structure Parser
======================

[](#email-structure-parser)

Given an IMAP stream and a message number, this library will parse the structure of multipart emails.

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

[](#installation)

You can easily install the Email Structure Parser package using the following Composer command.

```
composer require jord-jd/email-structure-parser
```

Usage
-----

[](#usage)

To use this parser, you must have first connect to a mail server using PHP's built-in `imap_open` function. Once connected, you then need to retrieve a message number, via the `imap_search` function.

Once you have a message number, you can pass it, along with the IMAP stream object, into the `EmailStructureParser`. You can then call the `getParts()` method to retrieve an array of parsed email parts split up by mime type.

See the example usage code below.

```
use JordJD\EmailStructureParser\EmailStructureParser;

// Connect to mailbox
$imapStream = imap_open('{outlook.office365.com:993/ssl/novalidate-cert}INBOX', getenv('USERNAME'), getenv('PASSWORD'));

// Get a message number (in this example, just get the first)
$msgNums = imap_search($imapStream, 'ALL');
$msgNum = $msgNums[0];

// Load message into parser
$parser = new EmailStructureParser($imapStream, $msgNum);

// Get parsed multipart email parts - including plain text and/or HTML content, and any attachments
$parts = $parser->getParts();

// Output HTML email content
var_dump($parts['TEXT/HTML']);

// Save attached PNG images
foreach($parts['IMAGE/PNG'] as $image) {
    file_put_contents($image->name, $image->content);
}
```

Content IDs
-----------

[](#content-ids)

Some emails embed images into the HTML content using `cid:` urls. These URLs link to the content ID of another part within the email, rather than being an absolute `https://` URL that can be resolved normally.

If one exists, this content ID will be exposed via the `contentId` property of the `Part`:

```
foreach($parts['IMAGE/PNG'] as $image) {
    // Store the file as in the above example:
    file_put_contents($image->name, $image->content);
    // You would then want to store this relationship in your database:
    echo "{$image->contentId} => {$image->name}\n";
}
```

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance83

Actively maintained with recent releases

Popularity18

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 94.1% 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 ~548 days

Recently: every ~685 days

Total

6

Last Release

88d ago

Major Versions

v1.0.0 → v2.0.02018-08-16

v2.2.0 → v3.0.02026-02-14

v3.0.0 → v4.0.02026-02-14

### Community

Maintainers

![](https://www.gravatar.com/avatar/c580cdf7c14898fff179cdfc1085892091d5d2f49d917873a12365af9ac77c93?d=identicon)[Jord-JD](/maintainers/Jord-JD)

---

Top Contributors

[![Jord-JD](https://avatars.githubusercontent.com/u/650645?v=4)](https://github.com/Jord-JD "Jord-JD (16 commits)")[![SteJaySulli](https://avatars.githubusercontent.com/u/60765965?v=4)](https://github.com/SteJaySulli "SteJaySulli (1 commits)")

---

Tags

emailemail-parseremail-parsingphpphp-library

### Embed Badge

![Health badge](/badges/divineomega-email-structure-parser/health.svg)

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

###  Alternatives

[tijsverkoyen/css-to-inline-styles

CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline styles. This is very useful when you're sending emails.

5.8k505.3M227](/packages/tijsverkoyen-css-to-inline-styles)[minishlink/web-push

Web Push library for PHP

1.9k12.0M53](/packages/minishlink-web-push)[laravel-notification-channels/twilio

Provides Twilio notification channel for Laravel

2587.7M12](/packages/laravel-notification-channels-twilio)[spatie/url-signer

Generate a url with an expiration date and signature to prevent unauthorized access

4422.3M16](/packages/spatie-url-signer)[mattketmo/email-checker

Throwaway email detection library

2742.0M5](/packages/mattketmo-email-checker)[laravel-notification-channels/discord

Laravel notification driver for Discord.

2371.3M11](/packages/laravel-notification-channels-discord)

PHPackages © 2026

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