承接 d4ry/imap-client 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

d4ry/imap-client

最新稳定版本:v1.0.9

Composer 安装命令:

composer require d4ry/imap-client

包简介

Socketbased IMAP Client for PHP

README 文档

README

Tests codecov Mutation testing badge Packagist Version Packagist Downloads License Apache 2.0

Raw-socket IMAP client for PHP 8.4+ — zero dependencies, full IMAPv4rev2 support.

Designed from scratch for modern PHP: speaks IMAP directly over sockets, fetches only what you ask for, and gives you full control over the protocol when you need it.

  • 🔌 Raw socket connection with TLS / STARTTLS
  • 📦 Zero runtime dependencies (only ext-mbstring + ext-openssl)
  • 📜 IMAPv4rev2 (RFC 9051) with 18+ extensions
  • 🪶 Lazy loading — bodies and attachments fetched on demand
  • 🎯 BODYSTRUCTURE-first — 50 MB email with a 12 KB text body? You download 12 KB
  • 🔎 Fluent search builder, IDLE + NOTIFY push, OAuth2 with token refresh

Installation

composer require d4ry/imap-client

Requirements: PHP 8.4+, ext-openssl, ext-mbstring

Quick Start

use D4ry\ImapClient\Auth\PlainCredential;
use D4ry\ImapClient\Config;
use D4ry\ImapClient\Mailbox;

$mailbox = Mailbox::connect(new Config(
    host: 'imap.example.com',
    credential: new PlainCredential('user@example.com', 'password'),
));

foreach ($mailbox->inbox()->messages() as $message) {
    echo $message->envelope()->subject . "\n";

    foreach ($message->attachments()->nonInline() as $attachment) {
        $attachment->save('/tmp');
    }
}

$mailbox->disconnect();

Search Example

use D4ry\ImapClient\Search\Search;

$search = (new Search())
    ->unread()
    ->from('notifications@github.com')
    ->after(new DateTime('-7 days'));

foreach ($mailbox->inbox()->messages($search) as $message) {
    printf("[%s] %s\n", $message->envelope()->from[0], $message->envelope()->subject);
    echo $message->hasHtml() ? $message->html() : $message->text();
}

More examples and the full API are in the documentation.

Benchmarks

Head-to-head benchmarks against webklex/php-imap and ddeboer/imap, run against a local Dovecot in Docker with 1 warmup + 10 measured runs per scenario. Time = median ms, memory = per-scenario delta in MB. Bold marks the row winner.

Scenario d4ry (ms / MB) webklex (ms / MB) ddeboer (ms / MB)
Fetch text body of large-attachment message 40.8 / 0.50 9,123.8 / 374.64 45.2 / 0.42
Search UNSEEN FROM x SINCE y 107.6 / 0.59 165.8 / 5.26 114.5 / 0.40
Cold open + read first 10 53.8 / 0.76 211.5 / 6.21 90.9 / 0.68

Results depend heavily on how each library is called — see docs/benchmarks.md for the full 7-scenario table and methodology. The adapters and raw data are auditable in D4ryB3rry/imap-client-benchmarks; PRs that improve any adapter are welcome.

Documentation

Guides

Reference

Advanced

License

Licensed under the Apache License 2.0.

统计信息

  • 总下载量: 22
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2026-04-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固