PHPackages                             aymanrb/php-mail-filters - 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. aymanrb/php-mail-filters

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

aymanrb/php-mail-filters
========================

A library to help you create GMAIL like mail filters in your PHP Application

v1.0.0(6y ago)31[1 PRs](https://github.com/aymanrb/php-mail-filters/pulls)MITPHPPHP &gt;=7.2.0CI passing

Since Nov 6Pushed 5mo ago2 watchersCompare

[ Source](https://github.com/aymanrb/php-mail-filters)[ Packagist](https://packagist.org/packages/aymanrb/php-mail-filters)[ Docs](https://github.com/aymanrb/mail_filters)[ RSS](/packages/aymanrb-php-mail-filters/feed)WikiDiscussions master Synced 3w ago

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

PHP Mail Filters Library
========================

[](#php-mail-filters-library)

[![Build Status](https://camo.githubusercontent.com/d3faa32bb84ebf11de103b96c21063c19260a01e7f111bd5e766d0df2504b9dc/68747470733a2f2f7472617669732d63692e6f72672f61796d616e72622f7068702d6d61696c2d66696c746572732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/aymanrb/php-mail-filters)[![Latest Stable Version](https://camo.githubusercontent.com/5d8548cec9da3bee0299df02edb36beb6aba50c8669b6595e06b431e5b6d3925/68747470733a2f2f706f7365722e707567782e6f72672f61796d616e72622f7068702d6d61696c2d66696c746572732f762f737461626c65)](https://packagist.org/packages/aymanrb/php-mail-filters)[![Latest Unstable Version](https://camo.githubusercontent.com/dbcc2d5bd152bf1c19fd5616a1fd31ad9aac458c7c4c7b928a402ca3d3dc7853/68747470733a2f2f706f7365722e707567782e6f72672f61796d616e72622f7068702d6d61696c2d66696c746572732f762f756e737461626c65)](https://packagist.org/packages/aymanrb/php-mail-filters)[![License](https://camo.githubusercontent.com/58a88032909f86e7957d769269630ae0b22d490811d1262cc7a722f624514ee7/68747470733a2f2f706f7365722e707567782e6f72672f61796d616e72622f7068702d6d61696c2d66696c746572732f6c6963656e7365)](https://packagist.org/packages/aymanrb/php-mail-filters)

This is a PHP package that enables you to create handy filtering features on E-mail messages (similar to that of Gmail filters feature) utilizing the [PHP IMAP extension](https://php.net/manual/book.imap.php). The library makes it easy to hook up your own IMAP connection to it, all you need to do is implement few adapter methods for your library needed for the filtering and actions functionality.

Currently the adapter is implemented for the following IMAP libraries:

- [ddeboer/imap](https://github.com/ddeboer/imap)
- [barbushin/php-imap](https://github.com/barbushin/php-imap)

### Features:

[](#features)

- **Apply filters your E-mail messages by setting criteria over the following fields:**

    - To
    - All Recipients (To, Cc, Bcc)
    - Subject
    - From
    - Body Text
    - Attachments
- **Take one of the following actions based on matched filters:**

    - Delete message from your mailbox.
    - Move the message to a different mail folder.
    - Copy the message to another mail folder.
    - Return user specified variables.
    - Mark message status (Read, Unread and Important)

### Requirements:

[](#requirements)

- PHP 7.2+
- PHP IMAP extension must be installed and activated
- A PHP IMAP library to read messages (preferably use one of the 2 listed above if you have none, or write an adapter to the one you are using)

### Example:

[](#example)

```
//Step 1: Build the filter(s) with Criteria and Actions
$mailFilter = new Filter();
$mailFilter
   ->setName('Move mails that contains "RID" in its subject to Tagged folder')
   ->addCriterion(new SubjectCriterion('*RID*'))
   ->addAction(new MoveMailAction('Tagged'));

$mailFilters = new MailFilter();
$mailFilters->addFilter($mailFilter);

// Step 2: Read the message
$mailbox = new PhpImap\Mailbox(
   '{imap.example.org:993/imap/ssl}INBOX',
   'username@example.org',
   'SecretPassword'
);

$mailMessageAdapter = new MailFilters\Adapters\BarbushinImap\MessageAdapter($mailbox);
$messageIds = $mailbox->searchMailbox('ALL');
$firstMessage = $mailbox->getMail();

// Step 3: Apply filters to message
$mailMessageAdapter->setMessage($firstMessage)
$mailFilters->applyFilters($mailMessageAdapter);
```

The above example will check if the given email contains "RID" in its subject and move the message to a new MailBox "Tagged" directory.

##### In Progress (Unfinished work):

[](#in-progress-unfinished-work)

- Adding unit and functional tests to the library

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance49

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity54

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

Unknown

Total

1

Last Release

2430d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0783b61c89c013e1e40add44e7fec40319fbb6fefeadc60d091f3a8a0a2aeb6e?d=identicon)[aymanrb](/maintainers/aymanrb)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/aymanrb-php-mail-filters/health.svg)

```
[![Health](https://phpackages.com/badges/aymanrb-php-mail-filters/health.svg)](https://phpackages.com/packages/aymanrb-php-mail-filters)
```

###  Alternatives

[maize-tech/laravel-email-domain-rule

Laravel Email Domain Rule

612.0k](/packages/maize-tech-laravel-email-domain-rule)[sarfraznawaz2005/noty

Laravel package to incorporate noty flash notifications into laravel.

324.5k](/packages/sarfraznawaz2005-noty)

PHPackages © 2026

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