Weave Code
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 Bundle

Imap Bundle Laravel Package

secit-pl/imap-bundle

Laravel bundle for IMAP email handling with a simple, configurable client. Connect to mailboxes, search and fetch messages, read headers and bodies, manage folders, and integrate IMAP operations into your Laravel app with minimal setup.

View on GitHub
Deep Wiki
Context7

Simple php-imap integration for Symfony

Frequently asked questions about Imap Bundle
Can I use this IMAP bundle directly in Laravel without Symfony?
No, this bundle is Symfony-centric and relies on its dependency injection and bundle system. However, you can extract its core `ImapClient` class and use it standalone in Laravel by requiring only the necessary Symfony components (like `symfony/dependency-injection`). This avoids full Symfony integration while keeping the IMAP logic.
What Laravel versions does this bundle support?
The bundle itself doesn’t natively support Laravel, but its underlying IMAP logic works with any Laravel 5.5+ version. You’ll need to manually bridge Symfony dependencies (e.g., via `symfony/dependency-injection`) and adapt configurations. Test thoroughly with your Laravel version, as Symfony’s DI may conflict with Laravel’s container.
How do I configure IMAP credentials securely in Laravel?
Store credentials in Laravel’s `.env` file (e.g., `IMAP_HOST`, `IMAP_USER`, `IMAP_PASS`) and load them into a Laravel config file (e.g., `config/imap.php`). Avoid hardcoding sensitive data. Use Laravel’s `env()` helper to dynamically inject values into the Symfony-style configuration the bundle expects.
Will this bundle work with Laravel’s queue system for background IMAP polling?
Yes, but you’ll need to wrap IMAP operations in Laravel jobs and dispatch them to queues (e.g., `php artisan queue:work`). The bundle’s stateful IMAP sessions may require connection pooling or caching (e.g., Redis) to avoid repeated logins. Test scalability under load, as IMAP polling can be resource-intensive.
Are there Laravel-specific alternatives to this Symfony IMAP bundle?
For pure Laravel solutions, consider custom IMAP libraries like `php-imap` (direct extension) or packages like `spatie/laravel-mail` (for sending/receiving). However, none offer the same bundled features (e.g., folder management, event-driven workflows) as this Symfony package. If you need IMAP’s full power, the bridge approach is worth the effort.
How do I mock IMAP interactions in Laravel tests (Pest/PHPUnit)?
Mock the `ImapClient` class or use PHP’s `imap_*` functions directly in tests with in-memory IMAP servers (e.g., `vpopmail` or Dockerized `dovecot`). For Symfony event testing, create Laravel event listeners that forward to the bundle’s events. Avoid testing real IMAP connections in CI; use stubs or fake implementations.
Does this bundle support OAuth2 for IMAP authentication?
No, the bundle uses basic IMAP authentication (username/password) via PHP’s `imap_open()`. For OAuth2, you’d need to extend the `ImapClient` class or pre-authenticate with an OAuth2 provider (e.g., Gmail) and pass the resulting token as a password. This requires custom logic outside the bundle’s core.
How do I handle IMAP connection timeouts or failures in Laravel?
Wrap IMAP operations in Laravel’s `try-catch` blocks and implement retry logic using packages like `spatie/laravel-retryable`. For persistent connections, cache the IMAP resource (e.g., `imap_open()` result) in Laravel’s cache or a singleton service. Log failures to Laravel’s `log()` system for debugging.
Can I use this bundle to process Gmail IMAP folders (e.g., 'All Mail', '[Gmail]/Sent')?
Yes, the bundle supports standard IMAP folder paths, including Gmail’s hierarchical folders (e.g., `{imap.gmail.com}/[Gmail]/Sent`). Ensure your IMAP credentials have the correct permissions, and use the bundle’s `search()` or `getMailbox()` methods to target specific folders. Gmail may require OAuth2 or app-specific passwords.
What’s the best way to integrate this bundle with Laravel’s event system?
Create Laravel event listeners that subscribe to Symfony events (e.g., `imap.message_received`). Use Laravel’s `Event::listen()` or `Bus::dispatch()` to trigger custom events. For example, dispatch a `EmailReceived` event in a Laravel service that wraps the bundle’s `ImapClient`. Map Symfony events to Laravel’s `EventServiceProvider` bindings.
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.
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
directorytree/privacy-filter-classifier
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi