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

ActiveYii2-extension[Mail &amp; Notifications](/categories/mail)

unyii2/yii2-imap
================

yii2 extension to read and process mails from IMAP and PHP

0.5.4(7y ago)455.1k↓35.3%5BSD-3-ClausePHPPHP &gt;=5.4.0

Since Dec 30Pushed 3y ago1 watchersCompare

[ Source](https://github.com/unyii2/yii2-imap)[ Packagist](https://packagist.org/packages/unyii2/yii2-imap)[ Docs](https://github.com/yiioverflow/yii2-imap.git)[ RSS](/packages/unyii2-yii2-imap/feed)WikiDiscussions master Synced today

READMEChangelog (5)DependenciesVersions (6)Used By (0)

yii2 Imap
=========

[](#yii2-imap)

[![Total Downloads](https://camo.githubusercontent.com/850bcf95d2cf3953a7eae3778058f8d753467fc6715fbee11efa8ee99e614879/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f756e796969322f796969322d696d61702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/unyii2/yii2-imap)

This library is a fork of

Installation by composer
------------------------

[](#installation-by-composer)

```
{
    "require": {
       "unyii2/yii2-imap": "dev-master"
    }
}

Or

$ composer require unyii2/yii2-imap "dev-master"

```

Use as compnent
===============

[](#use-as-compnent)

Connection details define in component

```
'components' => [
      ...
      'imap' => [
         'class' => 'unyii2\imap\Imap',
         'connection' => [
              'imapPath' => '{imap.gmail.com:993/imap/ssl}INBOX',
              'imapLogin' => 'username',
              'imapPassword' => 'password',
              'serverEncoding'=>'encoding', // utf-8 default.
              'attachmentsDir'=>'/'
        ],
    ],
    ...
 ],

//4th Param _DIR_ is the location to save attached files
//Eg: /path/to/application/mail/uploads.
$mailbox = new unyii2\Mailbox(yii::$app->imap->connection);
```

Usage as library
================

[](#usage-as-library)

Connection details set on fly

```
$imapConnection = new unyii2\imap\ImapConnection

$imapConnection->imapPath = '{imap.gmail.com:993/imap/ssl}INBOX';
$imapConnection->imapLogin = 'username';
$imapConnection->imapPassword = 'password';
$imapConnection->serverEncoding = 'encoding'; // utf-8 default.
$imapConnection->attachmentsDir = '/';

//4th Param _DIR_ is the location to save attached files
//Eg: /path/to/application/mail/uploads.
$mailbox = new unyii2\Mailbox($imapConnection);
```

\#To get all mails and its index

```
$mailbox->searchMailBox(ALL)// Prints all Mail ids.
print_r($mailIds);
```

\#Do not read attachments $mailbox-&gt;readMailParts = false;

\#To read Inbox contents

```
foreach($mailIds as $mailId)
{
    // Returns Mail contents
    $mail = $mailbox->getMail($mailId);

    if(alreadyProcesedMessage($mail->messageId)){
        continue;
    }

    // Use, if $mailbox->readMailParts = false;
    // Read mail parts (plain body, html body and attachments
    $mail = $mailbox->getMailParts($mail);

    // Returns mail attachements if any or else empty array
    $attachments = $mail->getAttachments();
    foreach($attachments as $attachment){
        echo ' Attachment:' . $attachment->name . PHP_EOL;

        // Delete attachment file
        unlink($attachment->filePath);

    }
}
```

\#To Mark and delete mail from IMAP server.

```
//Mark a mail to delete
$mailbox->deleteMail($mailId); // Deletes all marked mails
$mailbox->expungeDeletedMails();
```

Contribute
==========

[](#contribute)

Feel free to contribute. If you have ideas for examples, add them to the repo and send in a pull request.

Apreciate
=========

[](#apreciate)

Dont forgett o Leave me a "star" if you like it. Enjoy coding!

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~123 days

Total

5

Last Release

2614d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/542187ba859514d10d0952dca77df8ea889a9651b249d0b5b513da791fd2919b?d=identicon)[uldisn](/maintainers/uldisn)

---

Top Contributors

[![yiioverflow](https://avatars.githubusercontent.com/u/2894563?v=4)](https://github.com/yiioverflow "yiioverflow (34 commits)")[![uldisn](https://avatars.githubusercontent.com/u/3525344?v=4)](https://github.com/uldisn "uldisn (28 commits)")[![marcogermani87](https://avatars.githubusercontent.com/u/998645?v=4)](https://github.com/marcogermani87 "marcogermani87 (7 commits)")[![doctorpepper608](https://avatars.githubusercontent.com/u/2807984?v=4)](https://github.com/doctorpepper608 "doctorpepper608 (2 commits)")[![gatis-ozols](https://avatars.githubusercontent.com/u/30055755?v=4)](https://github.com/gatis-ozols "gatis-ozols (1 commits)")[![Sirgalas](https://avatars.githubusercontent.com/u/12089457?v=4)](https://github.com/Sirgalas "Sirgalas (1 commits)")

---

Tags

mailcronyii2extensionwidgetimapinbox

### Embed Badge

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

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

###  Alternatives

[roopz/yii2-imap

yii2 extension to read and process mails from IMAP and PHP

4098.0k](/packages/roopz-yii2-imap)[kartik-v/yii2-widget-growl

A widget to generate growl based notifications using bootstrap-growl plugin (sub repo split from yii2-widgets)

424.4M14](/packages/kartik-v-yii2-widget-growl)[kartik-v/yii2-widget-alert

A widget to generate alert based notifications using bootstrap-alert plugin (sub repo split from yii2-widgets)

304.2M24](/packages/kartik-v-yii2-widget-alert)[boundstate/yii2-mailgun

Mailgun integration for the Yii framework

28168.1k](/packages/boundstate-yii2-mailgun)[tigrov/yii2-mailqueue

Yii2 mail queue component for yii2-swiftmailer.

196.6k](/packages/tigrov-yii2-mailqueue)

PHPackages © 2026

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