PHPackages                             johnnymast/mailreader - 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. johnnymast/mailreader

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

johnnymast/mailreader
=====================

Get your email messages from mailserver

v1.2.1(9y ago)1261MITPHPPHP &gt;=5.6CI failing

Since Jan 22Pushed 8y ago2 watchersCompare

[ Source](https://github.com/johnnymast/mailreader)[ Packagist](https://packagist.org/packages/johnnymast/mailreader)[ RSS](/packages/johnnymast-mailreader/feed)WikiDiscussions master Synced today

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

[![Build Status](https://camo.githubusercontent.com/9900e812e08279fabd52f74d2e7907949fd646f79f1b45d1834190154428d383/68747470733a2f2f7472617669732d63692e6f72672f6a6f686e6e796d6173742f6d61696c7265616465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/johnnymast/mailreader)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/e18c7c784922ab99f021d23a876034d2bc7a68a632d1cfca9e720f634562278c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a6f686e6e796d6173742f6d61696c7265616465722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/johnnymast/mailreader/?branch=master)

MailReader
==========

[](#mailreader)

MailReader allows you to perform basic mail tasks like listing/moving and deleting mail on your mailserver. The following operations are supported out of the box.

- List/Delete/Move mail
- List/Create/Delete mailboxes (folders)

For some basic examples checkout the demos folder in this repository.

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

[](#requirements)

The following versions of PHP are supported by this version.

- PHP 5.6
- PHP 7.0
- PHP 7.1
- HHVM
- Php\_imap (core php extension)

Simple to use
-------------

[](#simple-to-use)

List email in your inbox.

```
use JM\MailReader\MailReader;

try {
    $reader = new MailReader();
    $reader->connect([
        'server'   => 'foobar.com',
        'username' => 'foo@bar.com',
        'password' => 'bar'
    ]);

    /**
     * Note: Uncomment the following line if
     *       you wish to read a mailbox (folder)
     */
    //$reader->setMailbox('Sent');

    // messages will now contain the emails you received
    $messages = $reader->readMailbox();

    if (is_array($messages) && count($messages) > 0) {
        foreach($messages as $email) {
            $header = $email['header'];

            // Assuming CLI here
            print $header->Subject."\n";
        }
    }
} catch (\Exception $e) {
    print $e->getMessage();
}
```

Find email sent to "" and display them (handy if you have a catch all mailbox).

```
use JM\MailReader\MailReader;

try {
    $reader = new MailReader();
    $reader->connect([
        'server'   => 'foobar.com',
        'username' => 'foo@bar.com',
        'password' => 'bar'
    ]);

    /**
     * Note: Uncomment the following line if
     *       you wish to read a mailbox (folder)
     */
    //$reader->setMailbox('Sent');

    // messages will now contain the emails you received
    $messages = $reader->readMailbox();

    if (is_array($messages) && count($messages) > 0) {
        foreach($messages as $email) {
            $header = $email['header'];

            // Assuming CLI here
            print $header->Subject."\n";
        }
    }
} catch (\Exception $e) {
    print $e->getMessage();
}
```

Filter unread email for  and move it to folder "Never seen mailbox". This mailbox (folder) will be created it it does not exist yet.

```
use JM\MailReader\MailReader;

/**
 * Note: port is an additional option to set.
 *       This option is not required.
 */
$reader->connect([
    'server'   => 'foobar.com',
    'username' => 'foo@bar.com',
    'password' => 'bar'
]);

$mailbox = 'Unread';
$targetEmailAddress = 'foo@bar.com';

// Create the mailbox (folder) if it does not already exist.
if ($reader->mailboxExists($mailbox) == false) {
    $reader->createMailbox($mailbox);
    $reader->subscribeMailbox($mailbox);
}

$messages = $reader->filterUnReadMessagesTo($targetEmailAddress);

if (is_array($messages) && count($messages) > 0) {
    foreach($messages as $message) {
        $reader->moveMessage($message['index'], $mailbox);
    }
}

// Switch to mailbox (folder) $mailbox
$reader->setMailbox('unseen');

// Retrieve the messages in mailbox (folder) $mailbox
$reader->setMailbox($mailbox);
$messages = $reader->readMailbox();
```

Author
------

[](#author)

This package is created and maintained by [Johnny Mast](https://github.com/johnnymast).

License
-------

[](#license)

The MIT License (MIT)

Copyright (c) 2017 Johnny Mast

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 96% 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 ~76 days

Recently: every ~96 days

Total

6

Last Release

3063d ago

### Community

Maintainers

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

---

Top Contributors

[![johnnymast](https://avatars.githubusercontent.com/u/121194?v=4)](https://github.com/johnnymast "johnnymast (24 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/johnnymast-mailreader/health.svg)

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

###  Alternatives

[symfony/polyfill-php73

Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions

2.4k595.3M79](/packages/symfony-polyfill-php73)[pclzip/pclzip

A PHP library that offers compression and extraction functions for Zip formatted archives

19313.2M4](/packages/pclzip-pclzip)[symfony/asset-mapper

Maps directories of assets &amp; makes them available in a public directory with versioned filenames.

1668.1M217](/packages/symfony-asset-mapper)[symfony/scheduler

Provides scheduling through Symfony Messenger

9012.8M98](/packages/symfony-scheduler)[elgentos/magento2-hyva-cro-semi-sticky-header

Changes the Hyvä header to a semi-sticky header (dissapears down and reappears up)

162.1k](/packages/elgentos-magento2-hyva-cro-semi-sticky-header)

PHPackages © 2026

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