PHPackages                             jhonn921007/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. [HTTP &amp; Networking](/categories/http)
4. /
5. jhonn921007/imap

AbandonedLibrary[HTTP &amp; Networking](/categories/http)

jhonn921007/imap
================

Receive and send e-mails over IMAP

0.4.3(11y ago)0224MITPHP

Since Nov 22Pushed 11y ago1 watchersCompare

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

READMEChangelog (3)Dependencies (2)Versions (8)Used By (0)

IMAP library
============

[](#imap-library)

[![Build Status](https://camo.githubusercontent.com/d11de5bf96e88f5f56560e50fe981c02487faa0ce1640511b1b33ba0de740884/68747470733a2f2f7472617669732d63692e6f72672f646465626f65722f696d61702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/ddeboer/imap)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/1c992d9bbb84a34b657f0adc908bc57166a4ef55dd0d659f0905331464928b9b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f646465626f65722f696d61702f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/ddeboer/imap/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/b992f5550c58f147803da18c0a4d4d0699c4bc957375f739320d80a541655026/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f646465626f65722f696d61702f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/ddeboer/imap/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/60410c03ccb8f20e6e36c399486becbf4ff915baed950fd98a1c9346793d5ca7/68747470733a2f2f706f7365722e707567782e6f72672f646465626f65722f696d61702f762f737461626c652e737667)](https://packagist.org/packages/ddeboer/imap)

A PHP 5.3+ library to read and process e-mails over IMAP.

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

[](#installation)

The recommended way to install the IMAP library is through [Composer](http://getcomposer.org):

```
$ composer require jhonn921007/imap:@stable
```

Usage
-----

[](#usage)

### Connect and authenticate

[](#connect-and-authenticate)

```
use Ddeboer\Imap\Server;

$server = new Server('imap.gmail.com');

// $connection is instance of \Ddeboer\Imap\Connection
$connection = $server->authenticate('my_username', 'my_password');
```

### Mailboxes

[](#mailboxes)

Retrieve mailboxes (also known as mail folders) from mailserver and iterate over them:

```
$mailboxes = $connection->getMailboxes();

foreach ($mailboxes as $mailbox) {
    // $mailbox is instance of \Ddeboer\Imap\Mailbox
    printf('Mailbox %s has %s messages', $mailbox->getName(), $mailbox->count());
}
```

Delete a mailbox:

```
$mailbox->delete();
```

### Messages

[](#messages)

Retrieve messages (e-mails) from a mailbox and iterate over them:

```
$messages = $mailbox->getMessages();

foreach ($messages as $message) {
    // $message is instance of \Ddeboer\Imap\Message
}
```

Get message number and unique [message id](http://en.wikipedia.org/wiki/Message-ID)in the form &lt;...&gt;:

```
$message->getNumber();
$message->getId();
```

Get other message properties:

```
$message->getSubject();
$message->getFrom();
$message->getTo();
$message->getDate();
$message->isAnswered();
$message->isDeleted();
$message->isDraft();
$message->isSeen();
```

Get message headers as a [\\Ddeboer\\Imap\\Message\\Headers](/src/Ddeboer/Imap/Message/Headers.php) object:

```
$message->getHeaders();
```

Get message body as HTML or plain text:

```
$message->getBodyHtml();
$message->getBodyText();
```

Reading the message body marks the message as seen. If you want to keep the message unseen:

```
$message->keepUnseen()->getBodyHtml();
```

Move a message to another mailbox:

```
$mailbox = $connection->getMailbox('another-mailbox');
$message->move($mailbox);
```

Deleting messages:

```
$mailbox->getMessage(1)->delete();
$mailbox->getMessage(2)->delete();
$mailbox->expunge();
```

### Message attachments

[](#message-attachments)

Get message attachments (both inline and attached) and iterate over them:

```
$attachments = $message->getAttachments();

foreach ($attachments as $attachment) {
    // $attachment is instance of \Ddeboer\Imap\Message\Attachment
}
```

Download a message attachment to a local file:

```
// getDecodedContent() decodes the attachments contents automatically:
\file_put_contents(
    '/my/local/dir/' . $attachment->getFilename(),
    $attachment->getDecodedContent()
);
```

Running the tests
-----------------

[](#running-the-tests)

This library is functionally tested on [Travis CI](https://travis-ci.org/ddeboer/imap)against the Gmail IMAP server.

If you have your own Gmail (test) account, you can run the tests locally:

```
$ composer install --dev
$ export EMAIL_USERNAME="your_gmail_username"
$ export EMAIL_PASSWORD="your_gmail_password"
$ vendor/bin/phpunit
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 83% 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 ~64 days

Recently: every ~31 days

Total

7

Last Release

4166d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/133bfd5d3bb40afa33f0e5d13adb76a8b19d64b75e8c7ac749aba2e06e0fda45?d=identicon)[daniel0707](/maintainers/daniel0707)

---

Top Contributors

[![ddeboer](https://avatars.githubusercontent.com/u/89267?v=4)](https://github.com/ddeboer "ddeboer (117 commits)")[![jhonnrodr](https://avatars.githubusercontent.com/u/5410179?v=4)](https://github.com/jhonnrodr "jhonnrodr (7 commits)")[![mvar](https://avatars.githubusercontent.com/u/1286752?v=4)](https://github.com/mvar "mvar (3 commits)")[![xelan](https://avatars.githubusercontent.com/u/5080535?v=4)](https://github.com/xelan "xelan (3 commits)")[![pepamartinec](https://avatars.githubusercontent.com/u/271753?v=4)](https://github.com/pepamartinec "pepamartinec (2 commits)")[![huglester](https://avatars.githubusercontent.com/u/150731?v=4)](https://github.com/huglester "huglester (1 commits)")[![jamesiarmes](https://avatars.githubusercontent.com/u/1030345?v=4)](https://github.com/jamesiarmes "jamesiarmes (1 commits)")[![oliverkaiser](https://avatars.githubusercontent.com/u/2995870?v=4)](https://github.com/oliverkaiser "oliverkaiser (1 commits)")[![abhinavkumar940](https://avatars.githubusercontent.com/u/1189133?v=4)](https://github.com/abhinavkumar940 "abhinavkumar940 (1 commits)")[![ysramirez](https://avatars.githubusercontent.com/u/5892242?v=4)](https://github.com/ysramirez "ysramirez (1 commits)")[![burci](https://avatars.githubusercontent.com/u/864531?v=4)](https://github.com/burci "burci (1 commits)")[![cidtal](https://avatars.githubusercontent.com/u/103543376?v=4)](https://github.com/cidtal "cidtal (1 commits)")[![cmoralesweb](https://avatars.githubusercontent.com/u/5377322?v=4)](https://github.com/cmoralesweb "cmoralesweb (1 commits)")[![cordoval](https://avatars.githubusercontent.com/u/328359?v=4)](https://github.com/cordoval "cordoval (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M317](/packages/friendsofsymfony-rest-bundle)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78126.4M414](/packages/react-http)[php-http/curl-client

PSR-18 and HTTPlug Async client with cURL

48247.0M383](/packages/php-http-curl-client)[smi2/phpclickhouse

PHP ClickHouse Client

83510.1M71](/packages/smi2-phpclickhouse)[paragonie/csp-builder

Easily add and update Content-Security-Policy headers for your project

5412.8M18](/packages/paragonie-csp-builder)[geocoder-php/common-http

Common files for HTTP based Geocoders

18722.1M64](/packages/geocoder-php-common-http)

PHPackages © 2026

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