dg/imap
最新稳定版本:v1.0.0
Composer 安装命令:
composer require dg/imap
包简介
Retrieval, processing, and manipulation of emails within a mailbox via POP3, IMAP and NNTP
README 文档
README
This IMAP Library for PHP provides an intuitive and easy-to-use interface to interact with POP3, IMAP and NNTP mail servers. It allows for operations such as connecting to mailboxes, fetching messages, handling message parts, and managing email content.
- Connect to IMAP servers with ease
- Fetch and manage email messages
- Handle different parts of an email such as attachments and text
- Decode email content and headers
- Supports message deletion and structure analysis
Installation
To install the library, you can use Composer. Run the following command in your project directory:
composer require dg/imap
It requires PHP version 8.1 with extension imap.
Connecting to a Mailbox
To connect to an IMAP mailbox, create an instance of the Mailbox class.
use DG\Imap\Mailbox; $mailbox = new Mailbox( '{imap.gmail.com:993/imap/ssl}', 'your_username@gmai.com', 'your_password', ); $mailbox->connect();
Fetching Messages
Fetch all messages from the mailbox:
$messages = $mailbox->getMessages(); foreach ($messages as $message) { echo $message->getSubject() . "\n"; }
Handling Message Parts
To handle different parts of a message, such as attachments:
foreach ($messages as $message) { $parts = $message->getParts(); foreach ($parts as $part) { // Process each part } }
Certainly, here's the additional information regarding error handling through exceptions:
Error Handling
In case of any issue, such as a failure to connect to the IMAP server, fetch messages, or process message parts, the library will throw an DG\Imap\Exception:
try { $mailbox->connect(); $messages = $mailbox->getMessages(); // ... additional operations } catch (DG\Imap\Exception $e) { echo 'Error: ' . $e->getMessage(); }
Support Project
Do you like this project?
统计信息
- 总下载量: 29
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2023-11-29