Skip to content

Commit

Permalink
Prepare docs for 1.0 (fix #69)
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeboer committed Feb 1, 2015
1 parent 1d45685 commit c0fd4be
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 11 deletions.
43 changes: 33 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ A PHP 5.4+ library to read and process e-mails over IMAP.
Installation
------------

Make sure the [PHP IMAP extension](http://php.net/manual/en/book.imap.php)
is installed. For instance on Debian:

```bash
# apt-get install php5-imap
```

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

```bash
Expand All @@ -20,14 +27,10 @@ This command requires you to have Composer installed globally, as explained
in the [installation chapter](https://getcomposer.org/doc/00-intro.md)
of the Composer documentation.

Requirements
------------
[PHP IMAP extension](http://php.net/manual/en/book.imap.php) installed

Usage
-----

### Connect and authenticate
### Connect and Authenticate

```php
use Ddeboer\Imap\Server;
Expand All @@ -38,9 +41,23 @@ $server = new Server('imap.gmail.com');
$connection = $server->authenticate('my_username', 'my_password');
```

#### Options

You can specify port, [flags and parameters](http://php.net/manual/en/function.imap-open.php)
to the server:

```php
$server = new Server(
$hostname, // required
$port, // defaults to 993
$flags, // defaults to '/imap/ssl/validate-cert'
$parameters
);
```

### Mailboxes

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

```php
Expand All @@ -52,6 +69,12 @@ foreach ($mailboxes as $mailbox) {
}
```

Or retrieve a specific mailbox:

```php
$mailbox = $connection->getMailbox('INBOX');
```

Delete a mailbox:

```php
Expand Down Expand Up @@ -143,7 +166,7 @@ $mailbox->getMessage(2)->delete();
$mailbox->expunge();
```

### Message attachments
### Message Attachments

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

Expand All @@ -158,14 +181,14 @@ foreach ($attachments as $attachment) {
Download a message attachment to a local file:

```php
// getDecodedContent() decodes the attachments contents automatically:
\file_put_contents(
// getDecodedContent() decodes the attachment’s 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)
Expand Down
2 changes: 1 addition & 1 deletion src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function getMailboxes()
*/
public function getMailbox($name)
{
if (!\in_array($name, $this->getMailboxNames())) {
if (!in_array($name, $this->getMailboxNames())) {
throw new MailboxDoesNotExistException($name);
}

Expand Down

0 comments on commit c0fd4be

Please sign in to comment.