Skip to content

Commit b5129dc

Browse files
Create README.md
1 parent 4990e9c commit b5129dc

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

src/README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<div align="center">
2+
3+
4+
<a href="https://ko-fi.com/francescobianco/goal?g=10">
5+
<img src="https://raw.githubusercontent.com/javanile/php-imap2/refs/heads/main/docs/banner.svg" />
6+
</a>
7+
8+
9+
</div>
10+
11+
---
12+
13+
# php-imap2 - Source Code
14+
15+
This folder contains the core source code of the **php-imap2** library — a modern and modular PHP wrapper for IMAP functions.
16+
17+
The goal of this library is to provide a clean, object-oriented interface for working with IMAP mailboxes, compatible with PHP native functions, while extending functionality with additional helpers and abstractions.
18+
19+
## Structure Overview
20+
21+
Each file in this directory implements a key feature of the library:
22+
23+
- **Acl.php** - IMAP Access Control List (ACL) support.
24+
- **BodyStructure.php** - Parses message body structure from `imap_fetchstructure()`.
25+
- **Connection.php** - Handles connection to the IMAP server and low-level operations.
26+
- **Errors.php** - Centralized error handling for IMAP operations.
27+
- **Functions.php** - Polyfilled or redefined IMAP functions to enhance compatibility.
28+
- **HeaderInfo.php** - Parses headers from IMAP messages.
29+
- **ImapHelpers.php** - Collection of utility methods used across the library.
30+
- **Mail.php** - High-level object representing an email message.
31+
- **Mailbox.php** - Abstraction for IMAP folders and mailbox information.
32+
- **Message.php** - Core representation of a single message, including metadata.
33+
- **Polyfill.php** - Ensures compatibility with environments missing certain IMAP features.
34+
- **Thread.php** - Parses and represents threaded conversations using `imap_thread()`.
35+
- **Timeout.php** - Timeout management for IMAP connections.
36+
37+
## Usage
38+
39+
This folder is not intended to be used directly. Instead, include the library via Composer and use the appropriate namespace in your code.
40+
41+
Example:
42+
43+
```php
44+
use PhpImap2\Connection;
45+
use PhpImap2\Mail;
46+
47+
// Connect to mailbox
48+
$connection = new Connection([
49+
'host' => 'imap.example.com',
50+
'user' => '[email protected]',
51+
'password' => 'yourpassword',
52+
]);
53+
54+
$mailbox = $connection->getMailbox('INBOX');
55+
$messages = $mailbox->getMessages();
56+
57+
foreach ($messages as $message) {
58+
echo $message->getSubject();
59+
}
60+
```
61+
62+
## Notes
63+
64+
- Inspired by [Roundcube](https://github.com/roundcube/roundcubemail) internals and IMAP structure.
65+
- Fully tested against various IMAP servers.
66+
- The source is modular and designed to allow testing and replacement of components.
67+
68+
## License
69+
70+
This library is open source and available under the [MIT License](../LICENSE).

0 commit comments

Comments
 (0)