hafael/azure-mailer-driver
Send Laravel mail through Azure Communication Services with this drop-in mail transport driver. Configure your Azure connection string and sender address, then use Laravel's Mail facade as usual.
Upgrade deliberately. v8.0.0 is a major release, so check your constraint first:
composer why hafael/azure-mailer-driver
composer require hafael/azure-mailer-driver:^8.0
Review your app’s Laravel/PHP versions against the package’s new composer.json constraints before rolling out.
Look first at config/mail.php and the package README. v8 registers an acs mail transport through Laravel’s native MailManager::extend hook. The canonical driver/transport name is now acs; the legacy azure configuration remains supported for compatibility.
Configure a mailer. Add an acs mailer using the credential keys documented by the package, then point MAIL_MAILER=acs at it:
'mailers' => [
'acs' => [
'transport' => 'acs',
// endpoint / access key / from address per package docs
],
],
If you already have a working azure mailer from v7, keep it for now and migrate on your own schedule.
First use case: send a transactional message through Laravel’s normal Mail API:
Mail::to($user)->send(new WelcomeMail($user));
The package should be transparent here—you are still using Laravel Mailables, notifications, and queued mail.
Clear cached config after changes:
php artisan config:clear
Mail::mailer('acs').acs mailer name for new code. Treat azure as a compatibility path for existing deployments. This makes future removals of the legacy alias less painful.Mail::mailer('acs')->to($user)->send(new ReceiptMail($order));
This is useful when default mail is SMTP but ACS is reserved for production transactional mail.ShouldQueue on Mailables or Mail::queue() to keep request latency predictable and benefit from Laravel’s retry/failed-job handling.config/mail.php so config caching works.MessageSending / MessageSent for logging and correlation IDs rather than wrapping every send call in custom logging.Mail::fake() for application behavior. Assert that the right Mailable was sent to the right recipient. Reserve real ACS calls for a small staging smoke test, not the main test suite.mail.mailers.acs.transport does not match the name registered by the package, Laravel will throw an “unsupported mail transport” style error. Confirm the exact key in the package README.azure support is a bridge, not a long-term strategy. Existing azure configs should continue to work in v8, but new implementations should use acs. Plan a migration and avoid defining both names unless you intentionally need two mailers.php artisan config:clear. For Octane or long-running queue workers, restart workers after config/deployment changes.mail.mailers.acs at runtime, set config before the mailer is first resolved, or purge the resolved mailer.failed_jobs monitoring and retry policies.Mail::mailer('acs')->raw('Test', function ($message) {
$message->to('[email protected]')->subject('ACS test');
});
This isolates transport/config issues from Mailable rendering issues.MailManager::extend, the same pattern can be used for other custom transports. Keep custom transport registration in a service provider and avoid colliding with the package’s acs transport name.How can I help you explore Laravel packages today?