Skip to content

Commit 1d58467

Browse files
committed
added README
1 parent 6c10dbe commit 1d58467

3 files changed

Lines changed: 126 additions & 0 deletions

File tree

.editorconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_size = 4
6+
indent_style = space
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.{js,ts,vue}]
12+
indent_size = 2
13+
14+
[*.md]
15+
trim_trailing_whitespace = false
16+
17+
[*.{yml,yaml}]
18+
indent_size = 2

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) arukompas <arukomp@gmail.com>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<div align="center">
2+
<p>
3+
<h1>Mail Parser for PHP<br/>Simple, fast, no extensions required</h1>
4+
</p>
5+
</div>
6+
7+
<p align="center">
8+
<a href="#features">Features</a> |
9+
<a href="#installation">Installation</a> |
10+
<a href="#credits">Credits</a>
11+
</p>
12+
13+
<p align="center">
14+
<a href="https://packagist.org/packages/opcodesio/mail-parser"><img src="https://img.shields.io/packagist/v/opcodesio/mail-parser.svg?style=flat-square" alt="Packagist"></a>
15+
<a href="https://packagist.org/packages/opcodesio/mail-parser"><img src="https://img.shields.io/packagist/dm/opcodesio/mail-parser.svg?style=flat-square" alt="Packagist"></a>
16+
<a href="https://packagist.org/packages/opcodesio/mail-parser"><img src="https://img.shields.io/packagist/php-v/opcodesio/mail-parser.svg?style=flat-square" alt="PHP from Packagist"></a>
17+
</p>
18+
19+
## Features
20+
21+
[OPcodes's](https://www.opcodes.io/) **Mail Parser** has a very simple API to parse emails and their MIME contents. Unlike many other parsers out there, this package does not require the [mailparse](https://www.php.net/manual/en/book.mailparse.php) PHP extension.
22+
23+
Has not been fully tested against RFC 5322.
24+
25+
## Get Started
26+
27+
### Requirements
28+
29+
- **PHP 8.0+**
30+
31+
### Installation
32+
33+
To install the package via composer, Run:
34+
35+
```bash
36+
composer require opcodesio/mail-parser
37+
```
38+
39+
### Usage
40+
41+
```php
42+
use Opcodes\MailParser\Message;
43+
44+
// Parse a message from a string
45+
$message = Message::fromString('...');
46+
// Or from a file location (accessible with file_get_contents())
47+
$message = Message::fromFile('/path/to/email.eml');
48+
49+
$message->getHeaders(); // get all headers
50+
$message->getHeader('Content-Type'); // 'multipart/mixed; boundary="----=_Part_1_1234567890"'
51+
$message->getFrom(); // 'Arunas <arunas@example.com>
52+
$message->getTo(); // 'John Doe <johndoe@example.com>
53+
$message->getSubject(); // 'Subject line'
54+
$message->getDate(); // DateTime object when the email was sent
55+
$message->getSize(); // Email size in bytes
56+
57+
$message->getParts(); // Returns an array of \Opcodes\MailParser\MessagePart, which can be html parts, text parts, attachments, etc.
58+
$message->getHtmlPart(); // Returns the \Opcodes\MailParser\MessagePart containing the HTML body
59+
$message->getTextPart(); // Returns the \Opcodes\MailParser\MessagePart containing the Text body
60+
$message->getAttachments(); // Returns an array of \Opcodes\MailParser\MessagePart that represent attachments
61+
62+
$messagePart = $message->getParts()[0];
63+
64+
$messagePart->getHeaders(); // array of all headers for this message part
65+
$messagePart->getHeader('Content-Type'); // value of a particular header
66+
$messagePart->getContentType(); // 'text/html; charset="utf-8"'
67+
$messagePart->getContent(); // '<html><body>....'
68+
$messagePart->getSize(); // 312
69+
$messagePart->getFilename(); // name of the file, in case this is an attachment part
70+
```
71+
72+
## Contributing
73+
74+
A guide for contributing is in progress...
75+
76+
## Security Vulnerabilities
77+
78+
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
79+
80+
## Credits
81+
82+
- [Arunas Skirius](https://github.com/arukompas)
83+
- [All Contributors](../../contributors)
84+
85+
## License
86+
87+
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

0 commit comments

Comments
 (0)