wemakecustom/swiftmailer-twig-bundle
A Symfony bundle that integrates Swiftmailer with Twig, letting you render email bodies from Twig templates and send them through SwiftMailer's mailer service.
composer require <vendor>/<package>:^1.1. v1.1 pulls in SwiftMailer 6 and therefore requires Symfony 3.3+ components — check composer why symfony/* before upgrading an existing app, since a stale Symfony 2.8/3.2 lock will block the install.php artisan vendor:publish --provider="<Vendor>\<Package>\<Package>ServiceProvider" — the mail transport settings usually land in config/mail.php or a package-specific config/<package>.php.Mail::extend() / Mail::mailer() or a MailManager override). Read the transport's send() method before anything else — it tells you exactly which SwiftMailer objects you're dealing with.// .env
MAIL_DRIVER=<package-driver>
Mail::to($user)->send(new WelcomeMail($user));
If that works, the transport is bound correctly and everything else is plain Laravel mail.v1.1 upgrade note: run composer update <vendor>/<package> and immediately php artisan config:clear && php artisan queue:restart. The SwiftMailer 6 jump is the only change in this release, but it is a major-version dependency bump, so treat it as a potentially breaking upgrade (see Gotchas).
Mail::send. The package is a transport concern; message construction should stay in app/Mail/*. This keeps you insulated if a future v1.x moves off SwiftMailer (SwiftMailer was deprecated in favour of Symfony Mailer, so expect that eventually).Mail::extend('mydriver', function (array $config) {
return new MyTransport(...);
});
Doing it in a service provider's boot() keeps it testable and avoids mutating Swift_Mailer after the fact.Mail::to($user)->queue(new WelcomeMail($user)) moves the Swift transport call onto the worker. This matters more for SMTP/API transports than for log/array, and it's the single biggest reliability win for bulk sends.config/mail.php and call Mail::mailer('bulk')->to(...).Mail::fake() short-circuits the transport entirely — great for asserting assertSent/assertQueued, useless for validating the package's credentials or connection. Pair it with a small integration test that sends one real message to a sink (Mailtrap, log driver, or a local SMTP catcher).Swift_Mailer instance the package exposes — typically via a container binding or an event listener that runs after the mailer is resolved. Prefer namespaced classes (Swift\Mailer, Swift\Plugins\LoggerPlugin) in new code.->from() in the Mailable's build() and let the package/config supply the default; mixing MAIL_FROM_ADDRESS with a Mailable-level from is the most common cause of "mail sends but looks wrong in Gmail".Swift\Message, Swift\Transport\...) while keeping Swift_* underscore aliases as a compatibility layer. Any package code, plugin, or app listener that type-hints Swift_Message should still work, but check every Swift_* reference in your own code and in third-party mail plugins — the underscore names are deprecated in SwiftMailer 6 and were removed in 7, so this is your chance to migrate.composer update --with-dependencies for the mail-related packages in one pass.Swift_Events_SendEvent or similar, re-verify they're still firing after the upgrade; silently-dropped listeners are the classic symptom.config:clear after touching mail config. config/mail.php is cached; a stale cache will happily keep using the old transport name while you debug a "driver not found" error. php artisan config:clear is step one for any mail problem.Mail::fake() hides transport breakage. Tests pass, production throws Connection could not be established with host. Keep one non-faked smoke test per mailer.storage/logs/laravel.log before assuming "it sent".withSwiftMessage() callback that captures $this), serialization can fail on the worker. Test with QUEUE_DRIVER=sync first, then a real queue connection.Mail::extend() (custom transport), Mail::mailer() (named config), withSwiftMessage() (final message tweaks — headers, attachments, custom headers), and the package's own service provider bindings for the Swift_Mailer singleton.Swift_* internals so the eventual Symfony Mailer migration is a transport swap, not a rewrite.How can I help you explore Laravel packages today?