Webklex PHP-IMAP

A pure-PHP IMAP and POP3 client for reading mailboxes, messages, and attachments without the native ext-imap extension.

Library
Composer
v6.2.0
452stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
51/100Fair
Development Activity0
Maintenance44
Community80
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
79/100Good
Architecture82
Code Quality80
Innovation78
Learning Curve76

Webklex PHP-IMAP is a self-contained IMAP client written entirely in PHP, so you can connect to mail servers, browse folders, and fetch messages without needing the native php-imap C extension installed or enabled. Because the protocol is implemented in userland, it works consistently across hosting environments and unlocks features the extension makes awkward, such as IMAP IDLE and OAuth authentication.

The library exposes an expressive, fluent API for searching mailboxes, reading message headers and bodies, decoding MIME parts, and downloading attachments. It also provides POP3 support, event hooks, and an optional Laravel-friendly configuration and facade layer for framework integration.

What You Get

  • A pure-PHP IMAP and POP3 protocol implementation with no ext-imap requirement
  • A fluent query builder for searching mailboxes by criteria like subject, sender, and date
  • Rich Message, Header, Part, Attachment, and Address objects with MIME decoding
  • IMAP IDLE support for real-time push notifications of new mail
  • OAuth and classic authentication plus an optional Laravel config/facade layer

Common Use Cases

  • Building mailbox sync or email-processing pipelines in PHP
  • Fetching and parsing incoming messages and their attachments
  • Watching a mailbox in real time via IMAP IDLE for new-mail automation
  • Connecting to providers like Gmail or Microsoft 365 using OAuth tokens

Under The Hood

Architecture - Client.php owns a connection (protocol implementations under src/Connection, including IMAP and legacy/streams variants) and hands out Folder objects; a Query builder assembles IMAP SEARCH criteria and returns Message instances. Each Message composes Header, Structure/Part, Attachment, and Address objects, with MIME/charset work delegated to Decoder classes and EncodingAliases. ClientManager and Config provide account configuration (and a Laravel-friendly layer), while Events fire on message and folder actions.

Tech Stack - PHP 8.0.2+ requiring the openssl, json, mbstring, iconv, libxml, zip, and fileinfo extensions, plus nesbot/carbon for dates, symfony/http-foundation, and illuminate/pagination. symfony/mime is a suggested add-on for broader format support. The IMAP/POP3 protocol itself is implemented in-package rather than via ext-imap.

Code Quality - A substantial PHPUnit suite under tests/ covers header parsing, message decoding, attachments, and protocol behavior against fixtures, which matters for a hand-rolled protocol parser. Code is organized by concern (connection, query, message parts, support traits) and the project has years of iteration and a large contributor base.

API Design - The public API reads fluently: ClientManager / Client::make(...), $client->getFolder('INBOX'), then ->query()->subject(...)->since(...)->get() yielding typed messages. Naming mirrors IMAP concepts closely, and optional facade/config integration keeps Laravel usage idiomatic; the breadth of extensions and options gives it a moderate learning curve.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search