PHPackages                             lasso/mail-parser-bundle - 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. lasso/mail-parser-bundle

ActiveSymfony-bundle[Mail &amp; Notifications](/categories/mail)

lasso/mail-parser-bundle
========================

Parse mails using the Zend framework libraries

v1.1.2(10y ago)414.5k↑136.8%4[3 issues](https://github.com/lassodatasystems/LassoMailParserBundle/issues)BSD-3-ClausePHP

Since Aug 7Pushed 7y ago13 watchersCompare

[ Source](https://github.com/lassodatasystems/LassoMailParserBundle)[ Packagist](https://packagist.org/packages/lasso/mail-parser-bundle)[ Docs](https://github.com/lassodatasystems)[ RSS](/packages/lasso-mail-parser-bundle/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (1)Versions (25)Used By (0)

\##Lasso Mail Parser [![Build Status](https://camo.githubusercontent.com/4d6151cc66c8850fb280736fbae3f78eeeca704c2d0b8a10058f4d350eec1ce4/68747470733a2f2f7472617669732d63692e6f72672f6c6173736f6461746173797374656d732f4c6173736f4d61696c50617273657242756e646c652e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/lassodatasystems/LassoMailParserBundle)

For when you want easy access to an email's content. The Zend Framework has classes to parse emails, but they can be a bit clunky to use. For example, emails are split into parts, and you have to loop over all the parts in an email (which itself is treated as a part) to access the content.

\#What it does

The Lasso Mail Parser offers a simple way to get either html or text content from an email, discarding file attachments. Should both html and text parts be given, html is preferred.

\#How it works

An email is parsed with the Zend mail parser. It's parts are then recursively grouped by content type, such as 'text/plain' or 'text/html'. If any html or text parts are found, they are concatenated and the result returned. If no such parts are found, null is returned.

The concatenation string is determined by a call to a user-defined function, which makes flexible concatenation possible.

\#Usage

As this is a symfony bundle, you can add this repository to your composer.json file:

Then request the parser like this:

```
$parser = $container->get('lasso_mail_parser.parser');

```

Of course, it can be used with dependency injection too by adding it to your services.xml as a parameter.

Once you have a parser instance, parse the raw email source like this:

```
$parser->parse(YOUR-EMAIL-BODY);

```

You can then use

```
$emailAddresses = $parser->getAllEmailAddresses();

```

to extract email address from the email. You can restrict the fields used for extraction by passing in an array with the field names you wish to use:

```
// Only retrieve recipients
$receiverEmailAddresses = $parser->getAllEmailAddress(['to', 'cc', 'bcc']);

```

Use

```
$content = $parser->getPrimaryContent();

```

to get the main content. This will be html if html is present, else it will be plain text. You can pass in a custom glue function:

```
$glue = function($contentType) {
    switch ($contentType) {
        case 'text/plain':
            return "\n====\n";

        case 'text/html':
            return '';
    }

    return '';
}

$content = $parser->getPrimaryContent($glue);

```

Now all html parts will be concatenated with hr-tags, and all text parts will be concatenated with newlines and '===='.

If you are processing emails send via envelope journaling (e.g. from Office365), you can access the enveloped email via

```
$parser->getEnvelopedEmail();

```

This will return a normal part, and you can access content/headers on it. To check if an email has an enveloped email as an attachment, you can use

```
$parser->hasEnvelopedEmail();

```

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance5

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~33 days

Recently: every ~20 days

Total

24

Last Release

3848d ago

Major Versions

v0.9.9 → v1.0.02013-09-30

### Community

Maintainers

![](https://www.gravatar.com/avatar/d40a96bd3b1f8ef027c689dd7e9c61546e9144e6b519a3c8c1f5a40340efc644?d=identicon)[trb](/maintainers/trb)

![](https://www.gravatar.com/avatar/4c19cb75022b2f40285d28212758fd2051a4cd909a0b9312dae6292fdff11b82?d=identicon)[zodeus](/maintainers/zodeus)

![](https://www.gravatar.com/avatar/59d2f91ff7163619a3ff8a2ff567ac08b6df27bbaf8e5455485fd23b7fd0ce2e?d=identicon)[saem](/maintainers/saem)

---

Top Contributors

[![saem](https://avatars.githubusercontent.com/u/288031?v=4)](https://github.com/saem "saem (11 commits)")[![LassoMike](https://avatars.githubusercontent.com/u/9343069?v=4)](https://github.com/LassoMike "LassoMike (8 commits)")[![zodeus](https://avatars.githubusercontent.com/u/238219?v=4)](https://github.com/zodeus "zodeus (7 commits)")[![aclarkd](https://avatars.githubusercontent.com/u/254815?v=4)](https://github.com/aclarkd "aclarkd (2 commits)")[![trb](https://avatars.githubusercontent.com/u/499521?v=4)](https://github.com/trb "trb (1 commits)")

---

Tags

mailemailzendSymfony2parsing

### Embed Badge

![Health badge](/badges/lasso-mail-parser-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/lasso-mail-parser-bundle/health.svg)](https://phpackages.com/packages/lasso-mail-parser-bundle)
```

###  Alternatives

[zbateson/mail-mime-parser

MIME email message parser

53947.9M69](/packages/zbateson-mail-mime-parser)[ddeboer/imap

Object-oriented IMAP for PHP

9163.9M10](/packages/ddeboer-imap)[propaganistas/laravel-disposable-email

Disposable email validator

5752.4M6](/packages/propaganistas-laravel-disposable-email)[coconutcraig/laravel-postmark

Laravel package for sending mail via the Postmark API

2152.8M1](/packages/coconutcraig-laravel-postmark)[voku/email-check

email-check (syntax, dns, trash, ...) library

534.0M4](/packages/voku-email-check)[mlocati/spf-lib

Parse, build and validate SPF (Sender Policy Framework) DNS records

67846.0k2](/packages/mlocati-spf-lib)

PHPackages © 2026

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