Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
zbateson committed Nov 24, 2015
1 parent 8ba1ea0 commit 19b6055
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2014, Zaahid Bateson
Copyright (c) 2014-2015, Zaahid Bateson
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
39 changes: 37 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[![Build Status](https://travis-ci.org/zbateson/MailMimeParser.svg?branch=master)](https://travis-ci.org/zbateson/MailMimeParser)

# zbateson/mail-mime-parser

Standalone, testable and PSR-compliant mail mime parser alternative to PHP's
imap* functions and pear libraries.

[![Build Status](https://travis-ci.org/zbateson/MailMimeParser.svg?branch=master)](https://travis-ci.org/zbateson/MailMimeParser)

The goals of this project are to be:

* Well written
Expand All @@ -17,3 +17,38 @@ To include it for use in your project, please install via composer:
```
composer require zbateson/mail-mime-parser
```

## Requirements

MailMimeParser requires PHP 5.4 or newer.

## Usage

```php
$mailParser = new ZBateson\MailMimeParser();

$handle = fopen('file.mime', 'r');
$message = $mailParser->parse($handle); // returns a ZBateson\Message
fclose($handle);

echo $message->getHeaderValue('from'); // [email protected]
echo $message->getHeader('from')->getName(); // Person Name
echo $message->getHeaderValue('subject'); // The email's subject

$res = $message->getTextStream(); // or getHtmlStream
echo stream_get_contents($res);

$att = $message->getAttachmentPart(0); // first attachment
echo $att->getHeaderValue('Content-Type'); // text/plain for instance
echo $att->getHeaderParameter( // value of "charset" part
'content-type',
'charset'
);
echo stream_get_contents(
$att->getContentRersourceHandle()
);
```

## License

BSD licensed - please see [license agreement](https://github.com/zbateson/MailMimeParser/blob/master/LICENSE).

0 comments on commit 19b6055

Please sign in to comment.