- Can I use webklex/php-imap in Laravel without enabling the php-imap extension?
- Yes, the package is designed to work entirely without the php-imap extension. It provides a pure-PHP implementation of IMAP, including OAuth2 and IDLE support, making it ideal for environments where the extension isn’t available, like shared hosting or Docker containers.
- How does webklex/php-imap handle OAuth2 authentication for Gmail or Exchange?
- The package fully supports OAuth2 authentication, including token refreshes and scopes. You’ll need to configure your OAuth credentials in the Laravel config or client manager, and the library handles the authentication flow seamlessly, including integration with providers like Google or Microsoft.
- Does webklex/php-imap support real-time email processing with IMAP IDLE?
- Yes, the package includes full IMAP IDLE support, allowing your Laravel application to receive real-time notifications when new emails arrive. This is particularly useful for applications requiring instant email processing, like chat systems or live notifications.
- What Laravel versions does webklex/php-imap support?
- The package is compatible with Laravel 5.5+ and PHP 7.4+. The latest versions (v6.x) require PHP 8.0+, while older versions (v5.x, v4.x) support PHP 7.0+. Check the [compatibility table](https://github.com/Webklex/php-imap#compatibility) for exact version mappings.
- How do I integrate webklex/php-imap with Laravel’s service container and configuration?
- Use the `webklex/laravel-imap` wrapper, which provides a ServiceProvider for easy registration. Configure your IMAP accounts in `config/imap.php`, then bind the client to Laravel’s container. The wrapper also supports events (e.g., `imap.message.fetched`) for reactive programming.
- Can I use the native php-imap extension as a fallback for better performance or edge cases?
- Yes, the package allows you to optionally enable the php-imap extension for improved decoding, handling of edge cases, or legacy POP3 support. Configure this in the client manager or Laravel config to switch between pure-PHP and native modes dynamically.
- How do I handle large email attachments or bulk operations efficiently?
- The package supports pagination for large datasets and batch operations. For attachments, you can stream them directly to storage (e.g., S3 or local filesystem) without loading everything into memory. Pair it with Laravel Queues for async processing of heavy operations.
- Are there alternatives to webklex/php-imap for IMAP in Laravel?
- Alternatives include native PHP’s `imap_*` functions (if the extension is available) or libraries like `spatie/laravel-mail`. However, `webklex/php-imap` stands out for its pure-PHP implementation, OAuth2/IDLE support, and deep Laravel integration, making it ideal for environments without the php-imap extension.
- How do I test webklex/php-imap without a live IMAP server?
- The package is mockable via its `ClientInterface`, allowing you to use tools like Mockery or Laravel’s testing helpers to simulate IMAP responses. The repository also provides Docker-based test IMAP servers for integration testing, ensuring your code works before deployment.
- What are the potential performance bottlenecks with webklex/php-imap in production?
- Heavy operations like fetching thousands of emails with attachments can strain memory or timeouts. Mitigate this by using pagination, Laravel Queues for async processing, and caching frequently accessed data. Monitor performance with Laravel’s logging and queue monitoring to catch issues early.