nette/mail
Nette Mail is a PHP library for composing and sending emails. Build MIME messages with text/HTML bodies, attachments, and embedded images, set headers and recipients, and send via SMTP or native mail() with a simple, reliable API.
Pros:
Mail facade while offering finer-grained control (e.g., custom SMTP contexts).CssInliner, SensitiveParameter), enabling static analysis and IDE tooling—critical for Laravel’s evolving ecosystem.MAIL_ENCRYPTION).CssInliner solves a pain point in Laravel’s email templating (inconsistent rendering across clients like Outlook).Cons:
Mailable class and Mail facade abstract email sending, while Nette/Mail requires manual message composition (e.g., Message object). This may introduce friction for teams accustomed to Laravel’s fluent API.swiftmailer/swiftmailer (Laravel’s default), Nette/Mail lacks built-in Laravel service provider bindings or facade support, requiring custom glue code.Message, Mailer interfaces) maps cleanly to Laravel’s architecture. Key integration points:
swiftmailer/swiftmailer with nette/mail in composer.json and extend Laravel’s MailManager to use Nette’s FallbackMailer.SmtpMailer, SendmailMailer) and inject them into services or Mailable classes.Mail facade for simple use cases via a decorator pattern.Mail facade can wrap Nette’s Message objects transparently.SmtpMailer constructor changes). Mitigate by:
CssInliner) may require tweaks for edge cases (e.g., Outlook’s vml support). Test with tools like Email on Acid.CssInliner uses regex and DOM parsing, which could impact high-volume email campaigns. Benchmark against SwiftMailer.Mailable classes to Nette’s Message objects?CssInliner and static analysis?Mailer instead of Laravel’s Mail facade?SmtpMailer, SendmailMailer) and inject them into controllers/services.config/mail.php to include Nette-specific settings (e.g., nette_mail.dkim).Message::setHtmlBody()/setTextBody().events system to hook into email sending (e.g., log messages before/after dispatch).Message objects to Laravel queues (e.g., Mailer::send($message) in a job).Mailable class to use Nette’s Message under the hood.MailFake or MailPretender to mock Nette’s Mailer interfaces.SmtpMailer with Laravel’s MAIL_HOST/MAIL_PORT configs.SmtpMailer with SES credentials via Laravel’s env() helpers.Phase 1: Pilot Project
nette/mail via Composer.NetteMailServiceProvider to bind mailers to Laravel’s container.Mailable class to use Nette\Mail\Message.MailFake and a staging SMTP server.Phase 2: Hybrid Integration
MailManager to support Nette’s FallbackMailer alongside SwiftMailer.Transport with Nette’s Mailer.// app/Providers/MailServiceProvider.php
public function boot()
{
$this->app->resolving('mail.manager', function ($manager) {
$manager->extend('nette', function ($app) {
return new FallbackMailer(
new SmtpMailer(...),
new SendmailMailer(...)
);
});
});
}
Phase 3: Full Migration
swiftmailer/swiftmailer from composer.json.Mailable classes to use Nette\Mail\Message.Mail facade with a custom facade wrapping Nette’s Mailer.MAIL_DRIVER=swift).How can I help you explore Laravel packages today?