PHPackages                             particlebits/imap - 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. particlebits/imap

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

particlebits/imap
=================

PHP class to access an IMAP mailbox. Specifically uses the Laminas library and not the IMAP extension.

2.2.0(4y ago)555.6k1[3 PRs](https://github.com/ParticleBits/imap/pulls)BSD-3-ClausePHPPHP &gt;=7.0

Since Dec 23Pushed 1y ago2 watchersCompare

[ Source](https://github.com/ParticleBits/imap)[ Packagist](https://packagist.org/packages/particlebits/imap)[ Docs](https://github.com/particlebits/imap)[ RSS](/packages/particlebits-imap/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (60)Used By (0)

Pb\\Imap
========

[](#pbimap)

Pb\\Imap is a library for downloading and parsing IMAP email messages. For performance reasons, the PHP IMAP extension is specifically *not* used, in favor of the Laminas Mail library.

Separate forks of the Laminas Mail and Laminas Mime libraries are used and kept as up to date as possible. These forks are needed to make minor but necessary updates that wouldn't be approved in time or at all by the Laminas maintainers.

Memory performance is the goal of this library and it's been stabilized and reduced as much as possible. Depending on file attachment downloads, this application uses on average 10-20 MB of memory, with a peak of up to 75-100 MB during large attachment downloads.

### Features

[](#features)

- Connect to mailbox via IMAP
- Get a listing of all folders
- Download email messages and save attachments to disk
- Search emails by custom criteria
- Get status information on each folder

### Installation by Composer

[](#installation-by-composer)

```
{
  "require": {
    "particlebits/imap": "^2.1"
  }
}

```

*or*

```
$> composer require particlebits/imap ^2.1

```

### Usage Example

[](#usage-example)

```
$mailbox = new \Pb\Imap\Mailbox(
    'imap.gmail.com',
    'something@gmail.com',
    '**********',
    'INBOX',
    __DIR__ .'/attachments',
    [
        \Pb\Imap\Mailbox::OPT_DEBUG_MODE => true
    ]);
$messageIds = $mailbox->searchMailBox('ALL');

foreach ($messageIds as $messageId) {
    $message = $mailbox->getMessage($messageId);
    print_r($message);
    print_r($message->getAttachments());
}
```

### Available Options

[](#available-options)

You can use the following options in the final argument of the Mailbox constructor:

- `OPT_DEBUG_MODE`This will write memory info to the screen
- `OPT_SKIP_ATTACHMENTS`Skips downloading message attachments. Useful for saving disk space.

### Notes

[](#notes)

This project originally used the PHP IMAP extension for fetching and parsing email messages. The extension is not very memory efficient for long-running processes, which is my intended use. Instead, this library uses the Laminas Mail package. Laminas Mail retrieves messages through a socket connection and parses the headers. \\Pb\\Imap takes this raw message object and converts into something more user-friendly.

For more examples see the scripts inside the `tests/` folder.

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance30

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 98.1% 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 ~40 days

Recently: every ~249 days

Total

58

Last Release

1510d ago

Major Versions

0.5.4 → 1.0.02015-12-30

1.2.3 → 2.0.02019-06-24

PHP version history (4 changes)0.1.0PHP &gt;=5.3.0

1.1.0PHP ^5.6 || ^7.0

1.2.3PHP &gt;=5.6

2.0.0PHP &gt;=7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4adc538cac0f186f01fa1d0e44150682928940423cecd291cc0f15ad671faf4a?d=identicon)[mikegioia](/maintainers/mikegioia)

---

Top Contributors

[![mikegioia](https://avatars.githubusercontent.com/u/387937?v=4)](https://github.com/mikegioia "mikegioia (101 commits)")[![netandreus](https://avatars.githubusercontent.com/u/313477?v=4)](https://github.com/netandreus "netandreus (2 commits)")

---

Tags

phpmailimapfetch

### Embed Badge

![Health badge](/badges/particlebits-imap/health.svg)

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

###  Alternatives

[php-imap/php-imap

Manage mailboxes, filter/get/delete emails in PHP (supports IMAP/POP3/NNTP)

1.7k12.9M42](/packages/php-imap-php-imap)[henrique-borba/php-sieve-manager

A modern (started in 2022) PHP library for the ManageSieve protocol (RFC5804) to create/edit Sieve scripts (RFC5228). Used by Cypht Webmail.

23125.7k2](/packages/henrique-borba-php-sieve-manager)[benhall14/php-imap-reader

A PHP class that makes working with IMAP in PHP simple.

3516.6k](/packages/benhall14-php-imap-reader)

PHPackages © 2026

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