nette/mail
Lightweight PHP mailer from the Nette framework: compose and send emails with SMTP support, MIME messages, attachments, HTML/text bodies, and headers. Sensible defaults, easy integration, and good testability for apps and services.
dev@example.com) during development, directly addressing a top pain point in Laravel apps (e.g., Laravel issue #4567). This supports faster iteration and reduces support tickets from misrouted emails.HtmlComposer decouples HTML pre-processing (CSS inlining, image embedding, subject extraction) from the Message class, enabling modular email composition. This supports:
HtmlComposer pipelines).Message::setHtmlBody() ensures zero migration risk for existing codebases.X-Original-* headers) enables audit trails for compliance (e.g., GDPR, HIPAA) and debugging complex routing (e.g., forwarded emails).[TEST]) streamlines internal review workflows without manual editing.HtmlComposer paves the way for email template libraries (e.g., MJML integration) or AI-generated emails (e.g., LLMs composing HTML + plain-text).dev@example.com).X-Original-*).logs/mail.log) or third-party tools (e.g., Mailtrap).For Executives: *"v4.1.2 eliminates two critical risks in our email workflow:
dev@example.com, saving hours of support time and preventing customer confusion.mail.redirect in .env."*For Engineering: *"v4.1.2 solves two major pain points with minimal effort:
Interceptor (DI: mail.redirect: dev@example.com):
To/Cc/Bcc to a safe address during dev.X-Original-* headers for debugging.[TEST]) for clarity.MailTracy Bar:
mail: debugger: false if needed.HtmlComposer (new):
$composer = new HtmlComposer();
$composer->inlineCss($html); // Accumulates stylesheets
$composer->embedImages(public_path('images'));
$plainText = $composer->generatePlainText(); // Auto-extracts from HTML
Message::setHtmlBody() still works unchanged.Tradeoffs:
composer require nette/tracy).Recommendation: High priority for teams sending HTML emails in dev or needing debugging tools. For plain-text-only apps, skip the HtmlComposer but adopt Interceptor + Tracy Bar."*
For Developers: *"New features that save time:
Dev Mode Safety:
Add this to .env to never send test emails to real users again:
MAIL_REDIRECT=dev@example.com
Original recipients are preserved in X-Original-To headers.
Debugging Made Easy:
With Tracy Debugger installed, sent emails appear in the Tracy Bar panel:
Toggle with:
config(['mail.debugger' => true]); // Auto-enabled in debug mode
HTML Email Superpowers:
Use HtmlComposer for reusable email processing:
$composer = new HtmlComposer();
$composer->inlineCss($html); // Handles @media, :hover, etc.
$composer->embedImages(storage_path('app/emails'));
$plainText = $composer->generatePlainText(); // Auto-generated from HTML
Pro Tip: Chain methods for modular templates:
$template = $composer
->inlineCss($html)
->embedImages(public_path('assets'))
->generatePlainText();
Breaking Changes:
Migration:
composer require nette/mail:v4.1.2
php artisan config:clear
Add to .env:
MAIL_REDIRECT=dev@example.com
MAIL_DEBUGGER=true
```"*
How can I help you explore Laravel packages today?