Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Imap Laravel Package

ddeboer/imap

A modern PHP IMAP library for reading mailboxes and messages. Connect to servers, list folders, fetch and search messages, inspect headers, bodies and attachments, flag or move mail, and work with UTF-8 folder names through a clean, object-oriented API.

Deep Wiki
Context7

Technical Evaluation

Architecture fit. ddeboer/imap is a framework-agnostic, object-oriented IMAP client rather than a Laravel package: no service provider, no publishable config, no facade. It exposes a small domain model (Server → Mailbox → Message → Part/Attachment) that maps cleanly onto Laravel service classes, jobs, and events. For a product that must read arbitrary hosted mailboxes — shared inboxes, support@ accounts, customer-owned IMAP accounts — this is the right layer of abstraction. It is the wrong tool for greenfield inbound mail (webhook-based providers such as Postmark, Mailgun, or SES inbound are cheaper, lower-latency, and far less operationally brittle), so the build/buy decision should be settled before adopting it.

Integration feasibility. Straightforward. A thin adapter (~1–3 engineer-days) covers connection construction, mailbox enumeration, message retrieval, and attachment persistence via Flysystem. The substantive work is the polling pipeline around it: UID watermarking (UIDVALIDITY/UIDNEXT, never sequence numbers), Message-ID-based deduplication, idempotent processing, and an error taxonomy. Budget 1–2 weeks for a production-grade poller, not for the library integration itself.

Technical risk. Moderate and well-understood, concentrated in three areas:

  • Authentication. Microsoft 365 has disabled basic auth for IMAP, and Google requires app passwords or OAuth2/XOAUTH2. Confirm the v2 connection layer supports XOAUTH2 before committing; if not, this is a blocker for the majority of business mailboxes.
  • MIME reality. Malformed headers, undeclared charsets, RFC 2231 filenames, winmail.dat, and inline images are routine. The library is well tested against Dovecot, but Exchange and Gmail label semantics (folders vs. labels, modified UTF-7 folder names) differ in ways that surface only in production.
  • Maintainership. 919 stars and a low opportunity score indicate a solid but niche library with a small contributor base and effectively single-maintainer risk. MIT licensing makes forking viable; treat that as the mitigation rather than a reason to avoid.

Key questions.

  1. Which providers must be supported, and is OAuth2 mandatory?
  2. What volume — mailboxes, messages/day, peak attachment size?
  3. What latency SLA? Sub-minute latency requires IDLE or webhooks, which changes the design.
  4. Do we need write operations (move, flag, delete), and what is the blast radius of a bug there?
  5. Build vs. inbound-email provider — has that been ruled out on evidence?
  6. Retention and PII obligations for stored bodies and attachments.

Integration Approach

Stack fit. Good, with one wrapper. Bind a configured Server factory as a singleton in a service provider, inject it into jobs, and keep the library's types out of controllers and domain models — map to internal DTOs/entities so the dependency stays swappable. Attachments stream to S3 via Flysystem; never hold raw message bodies in memory beyond one message at a time.

Migration path. Adopt behind an internal MailboxReader interface. If the application already uses webklex/laravel-imap, migrate by feature rather than by rewrite: implement the interface against ddeboer/imap, run both in shadow mode against a test mailbox, diff parsed output, then cut over per-mailbox. The absence of Laravel-specific coupling makes this cheap; the absence of a facade means you own the wiring, which is arguably an advantage for testability.

Compatibility. Requires PHP 8.x and modern Composer; verify the constraint against the app's floor and against Laravel's supported PHP matrix. The strategic win is that v2 no longer depends on ext-imap, which is unbundled and deprecated in current PHP releases — this removes a PECL install from the container image and a recurring upgrade hazard. Note that any other package still using ext-imap will keep that dependency alive in the image regardless.

Sequencing.

  1. Two-day spike: connect to one Gmail and one Exchange mailbox, fetch, parse attachments, confirm auth path.
  2. Ship the adapter plus a single-mailbox poller behind a feature flag.
  3. Add watermarking, deduplication, Cache::lock per mailbox, and structured logging.
  4. Add observability (per-mailbox lag, fetch failures, parse failures) and alerting.
  5. Scale to N mailboxes via a scheduled fan-out job; only then consider IDLE or provider APIs.

Operational Impact

Maintenance. Low code churn, but two ongoing obligations: tracking upstream releases (the v2 protocol rewrite is recent and will need patch releases), and owning provider-specific quirks yourself — there is no vendor to escalate to. Pin versions, review changelogs before upgrades, and keep the adapter small enough that forking is a weekend, not a quarter.

Support. Failures will be reported as "email didn't arrive in the app," not as IMAP errors. Invest early in a support-visible diagnostic: last successful poll per mailbox, last error, last processed UID. Without it, every ticket becomes an engineering investigation.

Scaling. IMAP is a polling protocol and scales linearly with mailbox count, not gracefully. Each mailbox is a stateful, latency-bound connection; providers impose hard limits (Gmail caps concurrent connections and daily bandwidth per account). Model capacity as mailboxes × poll frequency and expect to shard across queue workers. Laravel's long-lived queue workers are a real hazard here: stale connections, memory growth from leaked message objects, and timeouts mid-fetch. Enforce maxJobs/maxTime on the queue, set explicit socket timeouts, and reconnect per batch rather than holding sockets open.

Failure modes.

  • Silent stall — connection alive, no new mail detected. Detect with lag alerts, not exceptions.
  • Duplicate processing — caused by sequence-number-based fetching or missing locks. Mitigate with UID watermarks and per-mailbox locks.
  • Partial message — connection drops mid-attachment; must be atomic and retried, never half-persisted.
  • Auth expiry — OAuth refresh tokens revoked or app passwords rotated; needs a distinct, actionable error class and user-facing reconnection flow.
  • Server-side rate limiting or IP throttling — back off with jitter, do not retry immediately.
  • Destructive operations — a move/delete bug on a customer mailbox is unrecoverable and reputationally severe. Gate write operations behind explicit product intent and audit logging.

Ramp-up. One engineer familiar with Laravel queues and the IMAP model (UIDs, folders, MIME) can own this within a sprint; the library's test suite and clean API shorten the curve. The real ramp-up cost is domain knowledge — MIME edge cases and provider idiosyncrasies — which is durable, transferable, and worth the investment only if IMAP mailbox access is a genuine product requirement rather than an implementation shortcut around inbound webhooks.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core