Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Mail Laravel Package

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.

View on GitHub
Deep Wiki
Context7

A handy library for creating and sending emails in PHP

Frequently asked questions about Mail
Can I use Nette/Mail to replace Laravel’s default SwiftMailer without breaking existing email logic?
Yes, Nette/Mail is a drop-in replacement. Bind it in `MailServiceProvider` and Laravel’s `Mail::send()` methods will work unchanged. The `Message` class mimics SwiftMailer’s API, so only transport-specific code (e.g., SMTP config) needs updates.
How does Nette/Mail’s DKIM signing compare to Laravel’s built-in DKIM support?
Nette/Mail’s `DkimSigner` offers finer control (custom selectors, passphrases) and integrates directly with Laravel’s `config/mail.php`. Test with `testMode` in config before production to avoid misconfigurations. For most users, it’s more reliable than SwiftMailer’s DKIM.
Will Nette/Mail’s CSS inlining break my existing email templates?
Unlikely, but test complex CSS (e.g., `@media` queries, nested selectors) in Outlook. The `CssInliner` component uses optimized regex for PHP 8.2+, but avoid inline styles in Blade templates—let Nette handle it. Start with a subset of templates to validate compatibility.
How do I configure SMTP fallbacks if my primary server fails?
Use Nette’s `FallbackMailer` to chain transports (e.g., SMTP → Sendmail). In Laravel, extend the `Mailer` class to wrap `FallbackMailer` with priority logic. Example: `new FallbackMailer([new SmtpMailer($config), new SendmailMailer()])`.
Is Nette/Mail compatible with Laravel 10 and PHP 8.2+?
Yes, use **v4.x** for PHP 8.2+ (Laravel 10+). For older PHP (7.4–8.1), use **v3.x**. The package drops PHP 7.1 in v4.0 but adds PHPDoc types and static return hints for modern tooling like PHPStan.
How do I test email sending in Laravel’s unit tests with Nette/Mail?
Use Laravel’s `MailFake` facade as usual. Nette/Mail’s `Message` class integrates with it seamlessly. Example: `Mail::fake(); Mail::raw($message)->to('user@example.com'); Mail::assertSent()`. No additional setup is needed.
Can I use Blade templates with Nette/Mail, and how do I prevent XSS?
Yes, pass Blade output via `setHtmlBody(view('email.template'))`. To prevent XSS, **always use `{{ }}` (escaped) for dynamic content**—never `{{!! !!}}`. For user-generated HTML, sanitize with `htmlspecialchars()` before rendering.
What’s the performance impact of CSS inlining for bulk emails (e.g., newsletters)?
Benchmark against SwiftMailer: `CssInliner` uses single-pass regex (optimized for PHP 8.2+) and adds ~5–10ms per email. For high volume, pre-inline CSS in templates or use a queue (e.g., Laravel Horizon) to distribute load.
Are there alternatives to Nette/Mail for Laravel, and why choose this one?
Alternatives include SwiftMailer (default), PHPMailer, or Symfony Mailer. Nette/Mail stands out for its **DKIM integration**, **CSS inlining**, and **fallback logic**—all without third-party dependencies. It’s also ~30% lighter than SwiftMailer and aligns with Laravel’s modular design.
How do I handle attachments with Nette/Mail, especially for large files?
Use `addAttachment()` with file paths or streams. For large files, validate `Content-Disposition` headers and consider chunked uploads via `setRawBody()`. Example: `$message->addAttachment($filePath, ['contentType' => 'application/pdf'])`.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope