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

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

haogood/php-imap
================

Get email contents and attachments using php imap extension.

v1.0.1(8y ago)0451[1 issues](https://github.com/Haogood/PHP-IMAP/issues)MITPHPPHP &gt;=5.5.0

Since Mar 15Pushed 7y agoCompare

[ Source](https://github.com/Haogood/PHP-IMAP)[ Packagist](https://packagist.org/packages/haogood/php-imap)[ RSS](/packages/haogood-php-imap/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (2)DependenciesVersions (3)Used By (0)

[![Author](https://camo.githubusercontent.com/329ba22a3c82a1819de6017ee4889a0c5358121d34bee0f1632248bc46b39dea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f617574686f722d68616f676f6f642d626c75652e7376673f6c6f6e6743616368653d74727565267374796c653d666c61742d737175617265)](https://www.linkedin.com/in/benny-sun-%E5%AD%AB%E8%B1%AA-65663b100/)[![Release](https://camo.githubusercontent.com/846806b476956cd650ee4156ffde4428b5c53a785a72cec76407f5ab448ec835/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f72656c656173652d76312e302e302d626c75652e7376673f6c6f6e6743616368653d74727565267374796c653d666c61742d737175617265)](https://github.com/Haogood/PHP-IMAP/tree/v1.0.0)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Size](https://camo.githubusercontent.com/337cbecc52c9ec54dfb7954786f9a38f7936092fb8b56623d6fd8dd0805e1b86/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f73697a652d31396b2d627269676874677265656e2e7376673f6c6f6e6743616368653d74727565267374796c653d666c61742d737175617265)](https://github.com/Haogood/PHP-IMAP/archive/v1.0.0.zip)

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

[](#requirements)

- PHP &gt;= 5.5.0
- IMAP PHP Extension

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

[](#installation)

```
composer require haogood/php-imap

```

Initialize
----------

[](#initialize)

```
use IMAP\IMAPMailbox;
$host = '{imap.gmail.com:993/imap/ssl}';
$user = 'user@gmail.com';
$pwd = '******';
$mailbox = new IMAPMailbox($host, $user, $pwd);
```

Search
------

[](#search)

```
$emails = $mailbox->search('ALL');
```

Fetch header info
-----------------

[](#fetch-header-info)

```
foreach ($emails as $email) {

    // Header info
    $headerinfo = $email->fetchHeaderinfo();

    // Author
    $author = $headerinfo->from->personal;

    // Sender address
    $from = $headerinfo->from->mailbox.'@'.$headerinfo->from->host;

    // Timestamp
    $timstamp = $headerinfo->udate;

    // Contents
    $contents = $email->getBody();

}
```

Fetch attachments
-----------------

[](#fetch-attachments)

```
foreach ($emails as $email) {
    foreach($email->getAttachments() as $attachment) {

        // Filename
        $filename = $attachment->getFilename();

        // Extension
        $ext = $attachment->getExtension();

        // Attachment file
        $file = $attachment->getBody();

        // Attchment info
        $info = $attachment->getInfo();

    }
}
```

Reference
---------

[](#reference)

- [hakre/imap-attachment.php](https://gist.github.com/hakre/2363305)
- [electrictoolbox](https://www.electrictoolbox.com/extract-attachments-email-php-imap/)

License
-------

[](#license)

`haogood/php-imap` is licensed under [The MIT License (MIT)](LICENSE).

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.3% 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

2

Last Release

3030d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/96464502?v=4)[Haogood](/maintainers/Haogood)[@HaoGood](https://github.com/HaoGood)

---

Top Contributors

[![benny-sun](https://avatars.githubusercontent.com/u/22260295?v=4)](https://github.com/benny-sun "benny-sun (14 commits)")[![ErikThiart](https://avatars.githubusercontent.com/u/9626641?v=4)](https://github.com/ErikThiart "ErikThiart (1 commits)")

---

Tags

phpimappop3mailboxreceive emails

### Embed Badge

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

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

###  Alternatives

[php-imap/php-imap

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

1.7k13.4M49](/packages/php-imap-php-imap)[webklex/php-imap

PHP IMAP client

4466.7M24](/packages/webklex-php-imap)[jason-munro/cypht

Lightweight Open Source webmail written in PHP and JavaScript

1.6k157.9k](/packages/jason-munro-cypht)[benhall14/php-imap-reader

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

3519.6k](/packages/benhall14-php-imap-reader)[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.

28142.6k4](/packages/henrique-borba-php-sieve-manager)[tedivm/dovecottesting

An IMAP Testing Suite

312.4k7](/packages/tedivm-dovecottesting)

PHPackages © 2026

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