PHPackages                             cosmira/envelope - 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. cosmira/envelope

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

cosmira/envelope
================

An elegant PHP library for parsing and extracting structured email contents, including attachments and metadata.

0.0.1(10mo ago)074[4 PRs](https://github.com/cosmira/envelope/pulls)MITPHPPHP ^8.2CI passing

Since Jul 3Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/cosmira/envelope)[ Packagist](https://packagist.org/packages/cosmira/envelope)[ RSS](/packages/cosmira-envelope/feed)WikiDiscussions main Synced 1mo ago

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

cosmira/envelope
================

[](#cosmiraenvelope)

[![Tests](https://github.com/cosmira/envelope/actions/workflows/phpunit.yml/badge.svg)](https://github.com/cosmira/envelope/actions/workflows/phpunit.yml)[![Quality Assurance](https://github.com/cosmira/envelope/actions/workflows/quality.yml/badge.svg)](https://github.com/cosmira/envelope/actions/workflows/quality.yml)[![Coding Guidelines](https://github.com/cosmira/envelope/actions/workflows/code-style.yml/badge.svg)](https://github.com/cosmira/envelope/actions/workflows/code-style.yml)

Introduction
------------

[](#introduction)

An elegant PHP library for parsing and extracting structured email contents, including attachments, headers, and metadata. Built on top of the powerful [ZBateson\\MailMimeParser](https://github.com/ZBateson/MailMimeParser) package, it offers a clean and intuitive API that simplifies working with email data.

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

[](#installation)

You can install the package via Composer:

```
composer require cosmira/envelope
```

Usage
-----

[](#usage)

To use the `Envelope` class, instantiate it with raw email content.

```
use Cosmira\Envelope\Envelope;

$content = file_get_contents('path_to_email_file.eml');

$mail = new Envelope($content);
```

API Reference
-------------

[](#api-reference)

### `from()`

[](#from)

Get the sender’s email address.

```
$mail->from();
// "john@example.com"
```

### `fromName()`

[](#fromname)

Get the sender’s display name.

```
$mail->fromName();
// "John Doe"
```

### `to()`

[](#to)

Get the primary recipients as an array of `email => name` pairs.

```
$mail->to();
// Collection: ['jane@example.com' => 'Jane Doe']
```

### `cc()`

[](#cc)

Get the CC recipients as an array of `email => name` pairs.

```
$mail->cc();
// Collection: ['assistant@example.com' => 'Team Assistant']
```

### `bcc()`

[](#bcc)

Get the BCC recipients as an array of `email => name` pairs.

```
$mail->bcc();
// Collection: ['hidden@example.com' => 'Confidential']
```

### `subject()`

[](#subject)

Get the subject line of the email.

```
$mail->subject();
// "Project Kickoff Meeting"
```

### `date()`

[](#date)

Get the date the email was sent as a `DateTime` object.

```
$mail->date()->format('Y-m-d H:i:s');
// "2025-09-11 10:32:00"
```

### `text()`

[](#text)

Get the plain text content of the email.

```
$mail->text();
// "Hello team, the meeting is scheduled for tomorrow..."
```

### `html()`

[](#html)

Get the HTML content of the email.

```
$mail->html();
// "Hello team,The meeting is scheduled for tomorrow..."
```

### `attachments()`

[](#attachments)

Get all attachments as an array, with each item containing `name`, `mime`, and `content`.

```
$mail->attachments()->each(function ($file) {
    echo 'Filename:  ' . $file['name'] . PHP_EOL;
    echo 'MIME Type: ' . $file['mime'] . PHP_EOL;
    echo 'Content:   ' . $file['content'] . PHP_EOL;
}
```

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance71

Regular maintenance activity

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

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

319d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3c47797b11041f37c2eec74b09bc6619c8997467d690797ebad0e6ab7cb232b7?d=identicon)[tabuna](/maintainers/tabuna)

---

Top Contributors

[![tabuna](https://avatars.githubusercontent.com/u/5102591?v=4)](https://github.com/tabuna "tabuna (19 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")

---

Tags

parsermailmimeemailattachmentsemlmessage extraction

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/cosmira-envelope/health.svg)

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

###  Alternatives

[zbateson/mail-mime-parser

MIME email message parser

53949.2M79](/packages/zbateson-mail-mime-parser)[php-mime-mail-parser/php-mime-mail-parser

A fully tested email parser for PHP 8.0+ (mailparse extension wrapper).

9979.6M27](/packages/php-mime-mail-parser-php-mime-mail-parser)[nette/mail

📧 Nette Mail: A handy library for creating and sending emails in PHP.

5389.8M246](/packages/nette-mail)[directorytree/imapengine

A fully-featured IMAP library -- without the PHP extension

531175.4k4](/packages/directorytree-imapengine)[propaganistas/laravel-disposable-email

Disposable email validator

5762.6M6](/packages/propaganistas-laravel-disposable-email)[vaibhavpandeyvpz/phemail

A pure PHP MIME parser for parsing raw email files (.eml) with full support for multipart messages, nested structures, and RFC 2046 compliance.

33121.7k1](/packages/vaibhavpandeyvpz-phemail)

PHPackages © 2026

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