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.
symfony/console, symfony/dependency-injection) or Laravel’s Symfony bridge (e.g., laravel/symfony-component packages).SwiftMailer/Mail is optimized for sending, not receiving/parsing. This bundle could complement Laravel’s ecosystem for inbound email workflows (e.g., support tickets, webhooks via email).ContainerInterface, Bundle system, and EventDispatcher. Laravel’s service container is compatible but requires manual adaptation (e.g., wrapping the bundle in a Laravel service provider).imap_* functions, reducing boilerplate but requiring PHP’s IMAP extension (php-imap). Laravel’s ext-imap must be enabled.config/packages/imap.yaml. Laravel’s config/imap.php would need a custom loader or adapter.AppServiceProvider vs. Symfony’s ContainerAware).EventDispatcher vs. Laravel’s Events).SwiftMailer + a queue worker suffice?spatie/laravel-mail or custom IMAP libraries (e.g., php-imap).symfony/dependency-injection and symfony/http-kernel via Composer to bridge DI.config/ and create a ImapServiceProvider to bind Symfony services.ImapClient) into a standalone PHP library and consume it directly in Laravel.ImapClient class and test it in a Laravel service.use Secit\ImapBundle\Client\ImapClient;
class ImapService {
public function __construct(private ImapClient $client) {}
}
imap.yaml → config/imap.php.// config/imap.php
return [
'host' => env('IMAP_HOST'),
'port' => env('IMAP_PORT'),
];
imap.message_received) to Laravel events or listeners.event(new EmailReceived($message));
| Symfony Component | Laravel Equivalent |
|---|---|
ContainerInterface |
Laravel’s Container |
Bundle |
Laravel ServiceProvider |
EventDispatcher |
Laravel Events |
YamlFileLoader |
Laravel Config |
php-imap is enabled (php -m | grep imap).ext-imap in php.ini.composer require symfony/dependency-injection symfony/http-kernel
ImapServiceProvider in config/app.php.Mockery or PHPUnit)..env (never in config files).scheduler for periodic checks).^1.0).Log facade to forward critical events.\Log::debug('IMAP Error', ['error' => $e->getMessage()]);
connection facade or a pool (e.g., pimple/proxy).$client = new ImapClient($config);
$client->connect(); // Reuse connection across requests
database driver).| Failure Scenario | Mitigation Strategy |
|---|---|
| IMAP Server Unavailable | Retry logic with exponential backoff. |
| Authentication Failures | Circuit breaker pattern (e.g., spatie/laravel-circuitbreaker). |
| Large Email Attachments | Stream attachments to storage (e.g., S3). |
| Laravel Worker Crashes | Supervisor + queue retries. |
| Configuration Errors | Validate config/imap.php on boot. |
imap_open timeouts) need documentation.support@example.com and dispatch Laravel events").php artisan imap:test-connection).// app/Console/Commands/TestImapConnection.php
public function handle() {
$client = app(ImapClient::class);
if ($client->connect()) {
$this->info('IMAP connection successful!');
}
}
How can I help you explore Laravel packages today?