PHPackages                             smart/emailreader - 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. smart/emailreader

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

smart/emailreader
=================

Email reader and dispatcher powered by Gearman

0.1.2(7y ago)241MITPHPPHP &gt;=5.6

Since Aug 21Pushed 7y ago2 watchersCompare

[ Source](https://github.com/smart-io/email-reader)[ Packagist](https://packagist.org/packages/smart/emailreader)[ Docs](https://github.com/smart-io/email-reader)[ RSS](/packages/smart-emailreader/feed)WikiDiscussions master Synced today

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

EmailReader
===========

[](#emailreader)

[![Build Status](https://camo.githubusercontent.com/24f54ef9199983b1195caa5067bbe9216b542681a26bd6fc8e80438492c355a1/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f736d6172742d696f2f656d61696c2d7265616465722f6d61737465722e7376673f7374796c653d666c6174)](https://travis-ci.org/smart-io/email-reader)[![Latest Stable Version](https://camo.githubusercontent.com/dfba4da8debaf155c509087c8b50c7af00c8a67736cce14bf76095bbd9150e6e/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736d6172742d696f2f656d61696c2d7265616465722e7376673f7374796c653d666c6174)](https://packagist.org/packages/smart-io/email-reader)[![Total Downloads](https://camo.githubusercontent.com/a994c5ddc585bef1097c3352a0c2f37b112f138e1a0d5d8df4086a7eed2fd4dc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f736d6172742d696f2f656d61696c2d7265616465722e7376673f7374796c653d666c6174)](https://packagist.org/packages/smart-io/email-reader)[![License](https://camo.githubusercontent.com/cb6edc9c52fabc9ea0893f95bc77198b63b5715ffba6e7fbbf6c1a159332c4ea/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f736d6172742d696f2f656d61696c2d7265616465722e7376673f7374796c653d666c6174)](https://packagist.org/packages/smart-io/email-reader)

This library will read emails of a specific mailbox, will parse them and finally, dispatch them to handlers. [How to install](#installation)

This library is used to read email (you can inject your own by implementing the DriverInterface) :

Inside our Fetch driver, we used this library to parse the last email reply :

\##How is it working ?

1. This library contains a command which is gonna check all new emails in your mailbox and give them to gearman. 1 new email = 1 new task on gearman.
2. The gearman job will read the email, parse it and then, dispatch it to your application.
3. Once gearman is finished with this email, the email is move to another folder to mark it as processed.

\##configuration

ConfigDefaultDescriptiondomainAddress of your mail serveur (eg. imap.gmail.com)port143SSL port is usually 993, normal is 143serviceImapImap or PopusernameYou email username, most of the time it's your emailpasswordYour email passwordmain mailboxThe mailbox where this library will read new emailsprocessed mailboxWhere to move the emails once processed\###example :

```
use Smart\EmailReader\Config\EmailServerConfig;

$configs = (EmailServerConfig())
    ->setDomain('imap.gmail.com')
    ->setPort(993)
    ->setService(EmailServerConfig::IMAP)
    ->setUsername('my.email@gmail.com')
    ->setPassword('my_plain_text_password')
    ->setMainMailbox('INDEX')
    ->setProcessedMailbox('Processed');
```

\##Dispatch

This library come with a dispatcher base class which allows you to handle different kind of email. The handlers on the dispatcher work like a router on the email subject.

\###example

*Imagine we have support ticket system on our app. We want our customer to be able to reply directly to the email to add their reply in our ticket system.*

```
use Smart\EmailReader\Dispatcher\Dispatcher;

class DispatcherApp extends Dispatcher
{
    public function __construct()
    {
        $this->addDispatcher(new SupportEmailDispatcher());
        //you can add as many dispatchers as you want....
    }
}
```

```
use Smart\EmailReader\Dispatcher\Dispatcher;
use Smart\EmailReader\EmailEntity;

class SupportEmailDispatcher extends Dispatcher
{
    public function __construct()
    {
        $this->addHandler('#\[support\-(?[0-9]+)\]#i', [$this, 'handleNewReply']);
    }

    public function handleNewReply($matches, EmailEntity $email)
    {
        $ticketId = isset($matches['id']) ? (int)$matches['id'] : null;
        $newReply = $email->getLastReply();
        //your logic here...
    }
}
```

\###About dispatchers :

- The dispatcher don't stop at the first match, different regexs can overlap themself
- If you return false on a dispatcher, the dispatcher will stop there and complete the task
- Currently, you can only dispatch the email based on the subject

\##Installation

\###Dependencies

This should be place in your app container

```
$emailReader = new Fetch(
    new EmailServerConfig() //check the configuration section
);

$emailLoggerLogger = new EmailReaderLogger(
    '/log/path_to_your_log_file'
);
```

\###Gearman job

We use Sinergi gearman :

```
//add this in sinergi gearman :

new EmailReaderDispatchJob(
    $emailReader,
    new DispatcherApp(), //your own dispatcher
    $emailLoggerLogger
);
```

\###Register Command

We use symfony console :

```
$consoleApp = new ConsoleApplication();
$gearmanDispatcher = '...'; //get your gearman dispatcher

$consoleApp->add(
    new EmailReaderSendCommand(
        $gearmanDispatcher,
        $emailReader
    )
);
```

Finally, you just need to add a cron on that command every few minutes to read incoming email and dispatch them into your application.

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity50

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

Total

2

Last Release

2720d ago

### Community

Maintainers

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

---

Top Contributors

[![gabrielbull](https://avatars.githubusercontent.com/u/671923?v=4)](https://github.com/gabrielbull "gabrielbull (2 commits)")

---

Tags

emailreaderdispatcher

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/smart-emailreader/health.svg)

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

###  Alternatives

[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[laravel/framework

The Laravel Framework.

34.8k543.8M20.1k](/packages/laravel-framework)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

21866.0M1.7k](/packages/drupal-core)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

85036.3k](/packages/flow-php-flow)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6942.5M420](/packages/drupal-core-recommended)[kimai/kimai

Kimai - Time Tracking

4.8k9.0k1](/packages/kimai-kimai)

PHPackages © 2026

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