- Can I use nette/mail in Laravel without replacing SwiftMailer entirely?
- Yes, you can integrate nette/mail alongside Laravel’s SwiftMailer by extending Laravel’s transport classes (e.g., `SendmailTransport` or `Swift_SmtpTransport`) to use Nette’s `SendmailMailer` or `SmtpMailer`. This lets you leverage Nette’s features like DKIM or CSS inlining while keeping SwiftMailer’s queueing capabilities.
- How do I configure nette/mail to work with Laravel’s mail.php settings?
- Use Laravel’s `AppServiceProvider` to bind Nette’s mailer to the container, then map Laravel’s `config/mail.php` values (e.g., SMTP host, port) to Nette’s `SmtpMailer` constructor. For DKIM, add a `dkim` section to your config and pass it to the mailer’s `setDkim()` method.
- Does nette/mail support Laravel’s Mailable classes out of the box?
- Not natively, but you can create a wrapper facade or trait to convert Laravel’s `Mailable` objects into Nette’s `Message` format. For example, extract the subject, HTML body, and attachments from the `Mailable` and assign them to a new `Message` object before sending.
- Will nette/mail work with Laravel’s queue system for delayed emails?
- No, nette/mail lacks built-in queue support. To use it with Laravel queues, you’d need to manually dispatch a job that constructs and sends the email via Nette’s mailer. Alternatively, consider using a hybrid approach where SwiftMailer handles queued emails and Nette handles real-time ones.
- How do I handle attachments or embedded images in nette/mail with Laravel?
- Use Nette’s `Message::addAttachment()` for files and `Message::embedFile()` for inline images. For Laravel’s `Mailable` classes, extract attachments from the `attach()` method calls and embed them using Nette’s API. The `MimePart` class handles MIME encoding automatically.
- Is nette/mail compatible with Laravel 10 and PHP 8.1?
- No, nette/mail v4.x requires PHP 8.2+. For Laravel 10 (PHP 8.1+), use v3.1.x, which supports PHP 7.1+. However, v3.x lacks some features like CSS inlining or DKIM signing, so weigh your needs against the PHP upgrade path.
- Can I use nette/mail’s CSS inliner to optimize Laravel Blade emails?
- Yes, but you’ll need to manually render Blade templates to HTML first (e.g., using `view()->render()`) before passing the output to Nette’s `CssInliner`. This works well for static emails but may not integrate seamlessly with Laravel’s dynamic `Mailable` rendering.
- How do I debug or intercept emails sent with nette/mail in Laravel?
- Use Nette’s `Mailer::setInterceptor()` to redirect emails to a custom handler (e.g., `mail.redirect` in config). For Laravel’s debug tools, hook into Nette’s `Interceptor::$onSent` and log events to Horizon or Telescope via Laravel’s event system (`events.mail.sent`).
- Are there performance trade-offs when using nette/mail for bulk emails?
- Nette’s mailer is lightweight, but DKIM signing or CSS inlining may add latency. For bulk emails, avoid real-time sending—use Laravel’s queue system with SwiftMailer instead. If you must use Nette, test with large payloads to ensure `MimePart` handles attachments efficiently.
- What alternatives to nette/mail exist for Laravel, and when should I choose them?
- For Laravel, consider `spatie/laravel-mail` (for advanced templates) or sticking with SwiftMailer (for queueing). Use nette/mail if you need lightweight, DI-friendly email handling with features like DKIM or CSS inlining, but avoid it if you rely on Laravel’s queue system or need SwiftMailer’s failover logic.