PHPackages                             tigrov/email-reply - 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. tigrov/email-reply

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

tigrov/email-reply
==================

Email reply - passes reply messages to predefined objects.

1.0.4(6y ago)1121MITPHPPHP &gt;=7.1

Since Jul 9Pushed 6y agoCompare

[ Source](https://github.com/Tigrov/email-reply)[ Packagist](https://packagist.org/packages/tigrov/email-reply)[ RSS](/packages/tigrov-email-reply/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (1)Versions (6)Used By (1)

Email Reply
===========

[](#email-reply)

The library passes reply messages from email to predefined objects. It uses IMAP to connect email servers.

[![Latest Stable Version](https://camo.githubusercontent.com/63f2fd7c49e2c79b08726fba1d07020e28da79d29424df8de69800203d65c7a1/68747470733a2f2f706f7365722e707567782e6f72672f546967726f762f656d61696c2d7265706c792f762f737461626c65)](https://packagist.org/packages/Tigrov/email-reply)[![Build Status](https://camo.githubusercontent.com/c0965f1ecd0e503a1beac3145331381b1e612eae48172088c40f63e547616365/68747470733a2f2f7472617669732d63692e6f72672f546967726f762f656d61696c2d7265706c792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Tigrov/email-reply)

Limitation
----------

[](#limitation)

The library uses [ddeboer/imap](https://github.com/ddeboer/imap) and it requires:

- PHP &gt;= 7.1
- extensions `iconv`, `IMAP`, `mbstring`

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist tigrov/email-reply

```

or add

```
"tigrov/email-reply": "~1.0"

```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

First of all you need to configure your email server. Create special mailbox and redirect all the mails sent to non-existent mailboxes. The server must accepts IMAP connections.

Then you can take steps:

1. Create a model class with `ModelInterface` interface and implement the necessary methods (see `examples/Model.php`). ```
    class Model implements ModelInterface
    {
        public static function paramNames() {}

        public function paramValues() {}

        public static function buildFromParams($paramValues) {}

        public function emailReply($message) {}
    }
    ```
2. Create and configure `EmailReply` object. ```
    $config = [
        'classesMap' => [
            // key will be used as prefix for email address
            'model' => \Model::class,
            // email for reply will be like model5@domain.com
            // or
            // 'm' => \Model::class,
            // email for reply will be like m5@domain.com
            // where 5 is id of a model
        ],
    ];

    $emailReply = new EmailReply($config);
    ```
3. Send a email message with a special reply email address. ```
    $email = $emailReply->getReplyEmail($model, 'domain.com');

    // Send an email to somebody with the reply email $email
    // ...
    ```
4. Read your mailboxes using IMAP. For example as `cron` job. ```
    $server = new Server($host, $port);

    $connection = $server->authenticate($username, $password);

    $mailboxModels = Reader::getMailboxModels($connection);

    $messages = Reader::getIterator($mailboxModels);

    $emailReply->read($messages);

    $connection->expunge();
    ```
5. Each message will be passed to `ModelInterface::emailReply($message)` where you can precess them. ```
    class Model implements ModelInterface
    {
        // ...

        public function emailReply($message)
        {
            /** @var string $fromEmail email address of the sender */
            $fromEmail = $message->getFrom()->getAddress();

            /** @var string $fromName name of the sender */
            $fromName = $message->getFrom()->getName();

            /** @var string $content content from the replied message */
            $content = $message->getBodyHtml() ?: $message->getBodyText() ?: $message->getDecodedContent();

            // Parse the content to get only answer
            $content = EmailReplyParser::parseReply($content);

            // To do something with $content
            // e.g. add comment from $fromEmail to the object
        }
    ```

See [examples](https://github.com/tigrov/email-reply/examples) directory for examples.

Also see [EmailReply for Yii2](https://github.com/tigrov/yii2-email-reply).

Suggests
--------

[](#suggests)

You can use [willdurand/email-reply-parser](https://github.com/willdurand/EmailReplyParser) to parse only reply text from email messages.

```
$reply = EmailReplyParser::parseReply($content);
```

License
-------

[](#license)

[MIT](LICENSE)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity58

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

Total

5

Last Release

2495d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/77d285672dec831b7ce5746ab8bb1dd20fffe81fb9d11c232534686706de9697?d=identicon)[Tigros](/maintainers/Tigros)

---

Top Contributors

[![Tigrov](https://avatars.githubusercontent.com/u/8563175?v=4)](https://github.com/Tigrov "Tigrov (11 commits)")

---

Tags

emailreply

### Embed Badge

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

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

###  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

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

A PHP script to convert HTML into a plain text format

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

Parse emails without the mailparse extension

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

PHPackages © 2026

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