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

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

stevebauman/php-imap
====================

PHP IMAP client

v5.7.3(1y ago)153381[2 issues](https://github.com/stevebauman/php-imap/issues)MITPHPPHP ^8.1CI passing

Since Dec 23Pushed 1y ago4 watchersCompare

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

READMEChangelog (5)Dependencies (6)Versions (13)Used By (0)

PHP IMAP
========

[](#php-imap)

Integrate IMAP into your PHP application. A fork of the [webklex/php-imap](https://github.com/Webklex/php-imap) library.

[![](https://camo.githubusercontent.com/d173d6e11bc8e286b2aa11bdc633cedcc088b6da9f0c4e55ce3fc14379f5bf6c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f73746576656261756d616e2f7068702d696d61702f72756e2d74657374732e796d6c3f6272616e63683d6d6173746572267374796c653d666c61742d737175617265)](https://github.com/stevebauman/php-imap/actions)[![](https://camo.githubusercontent.com/a3095eacf44e429a915ed190cea95699387a813aa570a929837302134f461bb8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73746576656261756d616e2f7068702d696d61702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/stevebauman/php-imap)[![](https://camo.githubusercontent.com/e24c88c54db1aaf592f9b358bd9866d0780e854665f728618df2910910ee46c9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73746576656261756d616e2f7068702d696d61702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/stevebauman/php-imap)[![](https://camo.githubusercontent.com/aaed4810f177243ff26a43dcd57d60fe28805d1af035c41a95c81fcc8271b799/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f73746576656261756d616e2f7068702d696d61702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/stevebauman/php-imap)

Important

This fork is not maintained. View [ImapEngine](https://github.com/DirectoryTree/ImapEngine) for a better alternative.

Description
-----------

[](#description)

PHP IMAP is a library that helps you interact with mailboxes over IMAP.

The `imap` extension is not required to use this library. The protocol has been completely implemented in PHP.

Support for IDLE is also included, which provides the ability to await new messages (and act upon them) indefinitely.

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

[](#requirements)

PHP &gt;= 8.1

Documentation
-------------

[](#documentation)

Original Documentation: [php-imap.com](https://www.php-imap.com/)

Usage
-----

[](#usage)

### Connecting

[](#connecting)

```
use Webklex\PHPIMAP\ClientManager;

$manager = new ClientManager([
    'options' => [
        'debug' => true,
    ],
    'accounts' => [
        'default' => [
            'port' => 993,
            'host' => 'imap.example.com',
            'username' => 'user@example.com',
            'password' => 'secret',
            'encryption' => 'tls',
        ],
    ],
])

/** @var \Webklex\PHPIMAP\Client $client */
$client = $manager->account('default');

// Connect to the IMAP Server.
$client->connect();
```

### Fetching Messages

[](#fetching-messages)

To fetch messages from a folder, you may use the `messages` method:

```
/** @var \Webklex\PHPIMAP\Folder $folder */
$inbox = $client->getFolder('INBOX');

/** @var \Webklex\PHPIMAP\Support\MessageCollection $messages */
$messages = $folder->messages()->all()->get();

/** @var \Webklex\PHPIMAP\Message $message */
foreach($messages as $message) {
    echo $message->getSubject().'';

    echo 'Attachments: '.$message->getAttachments()->count().'';

    echo $message->getHTMLBody();

    // Move the current Message to 'INBOX.read'.
    if ($message->move('INBOX.read') == true) {
        echo 'Message has been moved';
    } else {
        echo 'Message could not be moved';
    }
}
```

### Awaiting New Messages (Idle)

[](#awaiting-new-messages-idle)

To await new messages, you may use the `idle` method:

> This method will listen for new messages indefinitely.

```
use Webklex\PHPIMAP\Message;

$client->getFolder('INBOX')->idle(function (Message $message) {
    // Do something with the new message.
}, timeout: 60); // in seconds
```

Tests
-----

[](#tests)

### Quick-Test / Static Test

[](#quick-test--static-test)

To disable all test which require a live mailbox, please copy the `phpunit.xml.dist` to `phpunit.xml` and adjust the configuration:

```

```

### Full-Test / Live Mailbox Test

[](#full-test--live-mailbox-test)

To run all tests, you need to provide a valid imap configuration.

To provide a valid imap configuration, please copy the `phpunit.xml.dist` to `phpunit.xml` and adjust the configuration:

```

```

The test account should **not** contain any important data, as it will be deleted during the test. Furthermore, the test account should be able to create new folders, move messages and should **not** be used by any other application during the test.

It's recommended to use a dedicated test account for this purpose. You can use the provided `Dockerfile` to create an imap server used for testing purposes.

Build the docker image:

```
cd .github/docker

docker build -t php-imap-server .
```

Run the docker image:

```
docker run --name imap-server -p 993:993 --rm -d php-imap-server
```

Stop the docker image:

```
docker stop imap-server
```

Known issues
------------

[](#known-issues)

ErrorSolutionKerberos error: No credentials cache file found (try running kinit) (...)Uncomment "DISABLE\_AUTHENTICATOR" inside your config and use the `legacy-imap` protocol

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community23

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 75.2% 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 ~0 days

Total

5

Last Release

486d ago

### Community

Maintainers

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

---

Top Contributors

[![Webklex](https://avatars.githubusercontent.com/u/2884144?v=4)](https://github.com/Webklex "Webklex (499 commits)")[![stevebauman](https://avatars.githubusercontent.com/u/6421846?v=4)](https://github.com/stevebauman "stevebauman (114 commits)")[![szymekjanaczek](https://avatars.githubusercontent.com/u/74879123?v=4)](https://github.com/szymekjanaczek "szymekjanaczek (8 commits)")[![Max13](https://avatars.githubusercontent.com/u/531249?v=4)](https://github.com/Max13 "Max13 (4 commits)")[![DasTobbel](https://avatars.githubusercontent.com/u/5870230?v=4)](https://github.com/DasTobbel "DasTobbel (3 commits)")[![laurent-rizer](https://avatars.githubusercontent.com/u/52099563?v=4)](https://github.com/laurent-rizer "laurent-rizer (3 commits)")[![thin-k-design](https://avatars.githubusercontent.com/u/4499116?v=4)](https://github.com/thin-k-design "thin-k-design (3 commits)")[![peanut24](https://avatars.githubusercontent.com/u/5346088?v=4)](https://github.com/peanut24 "peanut24 (2 commits)")[![netpok](https://avatars.githubusercontent.com/u/6945600?v=4)](https://github.com/netpok "netpok (2 commits)")[![Magiczne](https://avatars.githubusercontent.com/u/8850255?v=4)](https://github.com/Magiczne "Magiczne (2 commits)")[![InterLinked1](https://avatars.githubusercontent.com/u/24227567?v=4)](https://github.com/InterLinked1 "InterLinked1 (2 commits)")[![latypoff](https://avatars.githubusercontent.com/u/11870079?v=4)](https://github.com/latypoff "latypoff (2 commits)")[![dwalck](https://avatars.githubusercontent.com/u/61882865?v=4)](https://github.com/dwalck "dwalck (2 commits)")[![HelloSebastian](https://avatars.githubusercontent.com/u/76404254?v=4)](https://github.com/HelloSebastian "HelloSebastian (2 commits)")[![spanjeta](https://avatars.githubusercontent.com/u/2450836?v=4)](https://github.com/spanjeta "spanjeta (1 commits)")[![sulgie-eitea](https://avatars.githubusercontent.com/u/22835171?v=4)](https://github.com/sulgie-eitea "sulgie-eitea (1 commits)")[![Oliver-Holz](https://avatars.githubusercontent.com/u/49278665?v=4)](https://github.com/Oliver-Holz "Oliver-Holz (1 commits)")[![didi1357](https://avatars.githubusercontent.com/u/9483742?v=4)](https://github.com/didi1357 "didi1357 (1 commits)")[![hhniao](https://avatars.githubusercontent.com/u/12420958?v=4)](https://github.com/hhniao "hhniao (1 commits)")[![Korko](https://avatars.githubusercontent.com/u/43628?v=4)](https://github.com/Korko "Korko (1 commits)")

---

Tags

mailphp-imapimappop3webklex

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[webklex/php-imap

PHP IMAP client

4365.5M14](/packages/webklex-php-imap)[php-imap/php-imap

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

1.7k12.9M42](/packages/php-imap-php-imap)[webklex/laravel-imap

Laravel IMAP client

7164.2M13](/packages/webklex-laravel-imap)[directorytree/imapengine

A fully-featured IMAP library -- without the PHP extension

531175.4k4](/packages/directorytree-imapengine)[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)
