diff --git a/.docs/README.md b/.docs/README.md new file mode 100644 index 0000000..c224367 --- /dev/null +++ b/.docs/README.md @@ -0,0 +1,85 @@ +# Documentation + +## Setup + +Install the package using [Composer](https://getcomposer.org). + +```bash +composer require minetro/imap +``` + +## Usage + +### Reading emails + +```php +use Minetro\Imap\ImapReader; + +$reader = new ImapReader('{yourdomain.cz:143/imap}INBOX', $username, $password); +$emails = $reader->read(ImapReader::CRITERIA_UNSEEN); + +// Iterate all emails +foreach ($emails as $email) { + + // Iterate all email parts + for ($i = 0; $i < $email->countBodies(); $i++) { + + // Get text (encoded with right encoding) + $text = $email->getBodySectionText($i); + + echo $text; + } +} +``` + +### Search criteria + +You can use the following search criteria constants: + +| Constant | Description | +|----------|-------------| +| `ImapReader::CRITERIA_ALL` | All messages | +| `ImapReader::CRITERIA_UNSEEN` | Unread messages | +| `ImapReader::CRITERIA_SEEN` | Read messages | +| `ImapReader::CRITERIA_NEW` | New messages | +| `ImapReader::CRITERIA_RECENT` | Recent messages | +| `ImapReader::CRITERIA_ANSWERED` | Answered messages | +| `ImapReader::CRITERIA_UNANSWERED` | Unanswered messages | +| `ImapReader::CRITERIA_DELETED` | Deleted messages | +| `ImapReader::CRITERIA_UNDELETED` | Not deleted messages | +| `ImapReader::CRITERIA_FLAGGED` | Flagged messages | +| `ImapReader::CRITERIA_UNFLAGGED` | Unflagged messages | + +### Message flags + +You can set or unset flags on messages: + +```php +// Mark message as seen +$reader->flag($messageNumber, ImapMessage::FLAG_SEEN); + +// Mark message as flagged +$reader->flag($messageNumber, ImapMessage::FLAG_FLAGGED); + +// Unmark message +$reader->unflag($messageNumber, ImapMessage::FLAG_SEEN); +``` + +Available flags: + +| Constant | Flag | +|----------|------| +| `ImapMessage::FLAG_SEEN` | `\Seen` | +| `ImapMessage::FLAG_ANSWERED` | `\Answered` | +| `ImapMessage::FLAG_FLAGGED` | `\Flagged` | +| `ImapMessage::FLAG_DELETED` | `\Deleted` | +| `ImapMessage::FLAG_DRAFT` | `\Draft` | + +### Proxy IMAP functions + +The `ImapReader` class supports proxying any `imap_*` function through the magic `__call` method: + +```php +// Calls imap_status($connection, ...) +$reader->status($mailbox, SA_ALL); +``` diff --git a/readme.md b/readme.md index 3a00a3f..fe6bb25 100644 --- a/readme.md +++ b/readme.md @@ -1,40 +1,50 @@ -# Imap +[![](https://heatbadger.now.sh/github/readme/contributte/imap/)](https://heatbadger.now.sh/github/readme/contributte/imap/) + +

+ + + + +

+

+ + + + + +

+ +

+ Website contributte.org | Contact f3l1x.io | Twitter @contributte +

-Simple IMAP wrapper. +## Usage ------ +To install the latest version of `minetro/imap` use [Composer](https://getcomposer.org). -[![Downloads total](https://img.shields.io/packagist/dt/minetro/imap.svg?style=flat-square)](https://packagist.org/packages/minetro/imap) -[![Latest stable](https://img.shields.io/packagist/v/minetro/imap.svg?style=flat-square)](https://packagist.org/packages/minetro/imap) +``` +composer require minetro/imap +``` -## Discussion / Help +## Documentation -[![Join the chat](https://img.shields.io/gitter/room/minetro/nette.svg?style=flat-square)](https://gitter.im/minetro/nette?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +For details on how to use this package, check out our [documentation](.docs). -## Install +## Versions -```sh -$ composer require minetro/imap:~1.1.0 -``` +| State | Version | Branch | PHP | +|--------|---------|----------|---------| +| dev | `^1.2` | `master` | `>=8.2` | +| stable | `^1.1` | `master` | `>=8.2` | -## Usage +## Development -```php -use Minetro\Imap\ImapReader; - -$reader = new ImapReader('{yourdomain.cz:143/imap}INBOX', $username, $password); -$emails = $reader->read(ImapReader::CRITERIA_UNSEEN); - -// Iterate all emails -foreach ($emails as $email) { - - // Iterate all email parts - for ($i = 0; $i < $email->countBodies(); $i++) { - - // Get text (encode with right encoding..) - $text = $email->getBodySectionText($i); - - echo $text; - } -} -``` +See [how to contribute](https://contributte.org) to this package. This package is currently maintained by these authors. + + + + + +--- + +Consider to [support](https://contributte.org/partners.html) **contributte** development team. Also thank you for using this package.