PHPackages                             sourcepot/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. [Mail &amp; Notifications](/categories/mail)
4. /
5. sourcepot/email

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

sourcepot/email
===============

PHP class to convert an email into an array

v1.0.0(1y ago)068MITPHPPHP &gt;=8.0

Since Dec 6Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/SourcePot/email)[ Packagist](https://packagist.org/packages/sourcepot/email)[ Docs](https://datapool.info)[ RSS](/packages/sourcepot-email/feed)WikiDiscussions main Synced 1mo ago

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

Email package
=============

[](#email-package)

This email package contains only the scanner class and a test website yet.

Scanner class
-------------

[](#scanner-class)

The scanner class extracts the content and headers of an e-mail that is read in as a string. The result is available as an array. The e-mail formats of the Internet Text Message Standard (e.g. Thimderbird) or OLE (e.g. Outlook) are currently supported.

First steps using the Scanner class in your project
---------------------------------------------------

[](#first-steps-using-the-scanner-class-in-your-project)

Following code shows how an instance of the Scanner class is created and the email loaded into the scanner. The results can be retrieved using the getHeader() and getParts() methods:

```
$scanner = new SourcePot\Email\Scanner();
$scanner->load($email);

$emailTransferHeader = $scanner->getHeader();
$emailParts = $scanner->getParts();

```

The source for an email can be a file upload or an IMAP mailbox folder. In the following example, an IMAP mailbox folder is opened and "today's" emails are looped through. The emails will be represented as character strings. You will need to provide the correct {MAILBOX}, {USER} and {PASSWORD} for the email folder.

```
$scanner = new SourcePot\Email\Scanner();

$mbox=@imap_open({MAILBOX},{USER},{PASSWORD});

$errors=imap_errors();
// add error handling code here

$alerts=imap_alerts();
// add alarm handling code here

if (!empty($mbox)){
    $messages=imap_search($mbox,'SINCE "'.date('d-M-Y').'"');
    if ($messages){
        foreach($messages as $mid){
            $email=imap_fetchbody($mbox,$mid,"");
            $scanner->load($email);
            // add code here to process the resulting $emailParts, $emailTransferHeader
        }
    }
}

```

Test website
------------

[](#test-website)

A test website is part of the package. An e-mail can be uploaded as a file to a temporary directory via the test website and then processed by the scanner class.

To use classes of the package or the test website, you must install the package on your computer (in the web directory of your localhost). After installation, you can open the test website via your browser. The easiest way to install the package is to use Composer. First make sure that Composer is already installed and then use the command prompt to execute the installation command:

```
composer create-project sourcepot/email {... add target web-directory here ...}

```

Let's start with the following test email which contains an attachment (pdf-file):

[![Test email](./assets/test_message.png)](./assets/test_message.png)

The test email is dragged &amp; dropped form Thunderbird into the Windows file explorer:

[![Test copied to a folder on the computer](./assets/test_message_upload.png)](./assets/test_message_upload.png)

The test website is opened on the localhost. Select the email and upload the email, click the "Process" button to process the email. The e-mail transfer header and each e-mail part are displayed in a separate table. The folloing screenshot shows the test result, can you see the preview of attachment?

[![Test email uploaded and processed](./assets/test_message_test_page.png)](./assets/test_message_test_page.png)

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance49

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 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

Every ~16 days

Total

6

Last Release

444d ago

Major Versions

v0.5.0 → v1.0.02025-03-01

### Community

Maintainers

![](https://www.gravatar.com/avatar/203fc800c6762aad4804f2e278a35262e603691a057035ff200827499e53f434?d=identicon)[SourcePot](/maintainers/SourcePot)

---

Top Contributors

[![SourcePot](https://avatars.githubusercontent.com/u/115737488?v=4)](https://github.com/SourcePot "SourcePot (60 commits)")

---

Tags

emailoleoutlookthunderbirdemail

### Embed Badge

![Health badge](/badges/sourcepot-email/health.svg)

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

###  Alternatives

[egulias/email-validator

A library for validating emails against several RFCs

11.6k691.3M307](/packages/egulias-email-validator)[sendgrid/sendgrid

This library allows you to quickly and easily send emails through Twilio SendGrid using PHP.

1.5k47.5M164](/packages/sendgrid-sendgrid)[pelago/emogrifier

Converts CSS styles into inline style attributes in your HTML code

94944.1M110](/packages/pelago-emogrifier)[zbateson/mail-mime-parser

MIME email message parser

54149.2M79](/packages/zbateson-mail-mime-parser)[soundasleep/html2text

A PHP script to convert HTML into a plain text format

48519.5M75](/packages/soundasleep-html2text)[opcodesio/mail-parser

Parse emails without the mailparse extension

226.8M8](/packages/opcodesio-mail-parser)

PHPackages © 2026

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