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
Sendgrid Mailer

Sendgrid Mailer Laravel Package

symfony/sendgrid-mailer

Symfony Mailer bridge for SendGrid. Configure SMTP or API transport via DSN, choose region, handle event webhooks with optional signature validation, set suppression group headers, and schedule sends (API) using a Send-At date header.

View on GitHub
Deep Wiki
Context7

Symfony Sendgrid Mailer Bridge

Frequently asked questions about Sendgrid Mailer
Can I use symfony/sendgrid-mailer in Laravel without Symfony Mailer installed?
No, this package requires Symfony Mailer as a dependency. However, Laravel already includes Symfony Mailer under the hood (via `illuminate/mail`), so no additional installation is needed beyond `symfony/sendgrid-mailer`. The package integrates directly with Laravel’s Mail facade.
How do I configure SendGrid in Laravel’s mail.php for API vs. SMTP transport?
Use the `MAILER_DSN` format in your `.env` file. For API transport (recommended for advanced features like scheduling), use `sendgrid+api://KEY@default?region=us`. For SMTP, use `sendgrid+smtp://KEY@default?region=us`. Replace `KEY` with your SendGrid API key and `region` with your preferred SendGrid region (e.g., `eu`, `ap1`).
Does this package support email scheduling in Laravel?
Yes, but only via the API transport (`sendgrid+api`). Use `Mail::later()` in Laravel or add a `Send-At` header to your email with a `DateTimeInterface` object. This maps to SendGrid’s `send_at` parameter in their API. SMTP transport does not support scheduling.
How do I handle SendGrid webhooks in Laravel for delivery events or failures?
You’ll need to register Symfony’s `RemoteEvent` components via a service provider. Create a route in `config/routes.yaml` pointing to `mailer.webhook.request_parser.sendgrid`, then implement a consumer class annotated with `#[AsRemoteEventConsumer(name: 'sendgrid')]`. This consumer will receive `MailerDeliveryEvent` objects for events like opens or bounces.
What Laravel versions and PHP versions are supported by symfony/sendgrid-mailer?
This package requires PHP 8.4+ and works with Laravel 10.x or later, as it depends on Symfony Mailer 6.4+. Laravel 9.x may work but isn’t officially supported. Always check the package’s `composer.json` for the latest compatibility notes, as dependencies may evolve.
How do I add suppression groups (e.g., for GDPR opt-outs) to emails in Laravel?
Use the `SuppressionGroupHeader` class from the package. Add it to your email’s headers like this: `$email->getHeaders()->add(new SuppressionGroupHeader('your_group_id', ['group1', 'group2']));`. This maps to SendGrid’s suppression groups, allowing you to manage unsubscribes or compliance groups dynamically.
Are there alternatives to symfony/sendgrid-mailer for Laravel?
Yes, alternatives include `laravel-notification-channels/sendgrid` (official Laravel channel driver) or `spatie/laravel-sendgrid-driver`. The Symfony package is ideal if you need advanced features like API transport, webhooks, or suppression groups. For simpler use cases, the Laravel channel driver may suffice.
How do I test SendGrid webhook signatures in Laravel before going to production?
Configure the `secret` in your Symfony webhook route (e.g., `secret: '!SENDGRID_VALIDATION_SECRET!'`) and validate signatures in your consumer. Use SendGrid’s sandbox mode to simulate webhooks locally. Test with both valid and invalid signatures to ensure your Laravel app handles failures gracefully.
What happens if SendGrid’s API rate limits are hit during high-volume email sends in Laravel?
Laravel’s queue system (e.g., database or Redis) will buffer emails until the rate limit resets. Implement exponential backoff in your queue workers or use a circuit breaker to fall back to SMTP temporarily. Monitor SendGrid’s API dashboard for rate limit alerts and adjust your Laravel queue batch sizes accordingly.
Can I migrate from a custom SwiftMailer setup to symfony/sendgrid-mailer in Laravel?
Yes, but you’ll need to replace your SwiftMailer-specific logic with Symfony Mailer’s API. Start by updating your `MAIL_MAILER` in `config/mail.php` to `sendgrid` and configure the `MAILER_DSN`. Test incrementally, replacing one mail driver at a time. Some SwiftMailer-specific features may require rewrites, but core functionality (e.g., sending emails) translates directly.
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.
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
ecotone/kafka
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata