- Can I use symfony/postmark-mailer directly in Laravel without modifying core files?
- No, this package isn’t Laravel-native. You’ll need to create a custom transport class (e.g., `PostmarkTransport`) extending Laravel’s `Swift_Transport` or use PSR-15 middleware to bridge Symfony’s Mailer with Laravel’s Mail facade. This requires minimal core changes but adds flexibility for retries and event handling.
- What Laravel versions support symfony/postmark-mailer?
- The package works with Laravel 10.x+ due to Symfony Mailer 6.x compatibility. For older Laravel versions (e.g., 9.x), you’d need to manually resolve dependency conflicts or use a wrapper like `spatie/laravel-postmark` instead, which offers tighter integration.
- How do I configure Postmark’s SMTP fallback if their API is down?
- Use Laravel’s queue system to retry failed API calls, then fall back to SMTP via Symfony’s Dsn (e.g., `postmark+smtp://api_key@client_id`). Configure this in your `PostmarkTransport` class by checking API response codes and switching drivers dynamically.
- Does this package support Postmark’s inbox preview tokens or message streams?
- Yes, but you’ll need to extend Laravel’s `Mailable` or `Notification` classes to inject Postmark-specific metadata (e.g., preview tokens) during message composition. Use Symfony’s `TemplatedEmail` to dynamically populate template variables for message streams.
- Can I queue emails with Postmark via Laravel’s queue workers?
- Absolutely. Wrap Postmark API calls in a Laravel job (e.g., `SendWithPostmark`) and dispatch them via `Mail::to()->send()` with the `queue` method. This leverages Laravel’s queue drivers (database/Redis) for retries and monitoring.
- What’s the performance impact of using Symfony Mailer in Laravel?
- Minimal if configured correctly. Symfony Mailer’s overhead is offset by its robust features (e.g., retries, event dispatching). Benchmark your setup by comparing latency between direct Postmark API calls (via Guzzle) and this package—differences are typically under 100ms for most use cases.
- How do I test Postmark email delivery in Laravel’s CI pipeline?
- Mock the `PostmarkTransport` class in PHPUnit to intercept API calls, then assert message composition and queue dispatch. Use Laravel’s `MailFake` for SMTP tests, but replace it with a custom `PostmarkFakeTransport` for API-specific validation.
- Is there a simpler alternative to symfony/postmark-mailer for Laravel?
- Yes, consider `spatie/laravel-postmark` for tighter Laravel integration (e.g., built-in queue support, notifications). However, it lacks Symfony’s advanced features like event dispatching or hybrid SMTP/API fallbacks. Choose based on whether you prioritize simplicity or robustness.
- How do I handle Postmark’s API rate limits in a Laravel app?
- Implement circuit breakers (e.g., `spatie/laravel-circuitbreaker`) to pause retries during failures. Configure exponential backoff in your `PostmarkTransport` class, and log rate-limit events to Laravel’s `failed_jobs` table for monitoring.
- Can I use this package with Laravel Notifications (e.g., password resets)?
- Yes, extend Laravel’s `Mailable` or override the `via()` method in notifications to use your `PostmarkTransport`. For example: `public function via($notifiable) { return [new PostmarkChannel]; }`. This ensures notifications use Postmark’s API while retaining Laravel’s queue and retry logic.