symfony / sendgrid-mailer
Symfony Sendgrid Mailer Bridge
Package info
github.com/symfony/sendgrid-mailer
Type:symfony-mailer-bridge
pkg:composer/symfony/sendgrid-mailer
Requires
- php: >=8.4.1
- symfony/mailer: ^7.4|^8.0
Requires (Dev)
- symfony/http-client: ^7.4|^8.0
- symfony/webhook: ^7.4|^8.0
Conflicts
- symfony/webhook: <7.4
This package is auto-updated.
Last update: 2026-06-05 06:51:36 UTC
README
Provides Sendgrid integration for Symfony Mailer.
Configuration example:
# SMTP MAILER_DSN=sendgrid+smtp://KEY@default?region=REGION # API MAILER_DSN=sendgrid+api://KEY@default?region=REGION
where:
KEYis your Sendgrid API KeyREGIONis Sendgrid selected region (default to global)
Webhook
Create a route:
framework: webhook: routing: sendgrid: service: mailer.webhook.request_parser.sendgrid secret: '!SENDGRID_VALIDATION_SECRET!' # Leave blank if you don't want to use the signature validation
And a consume:
#[\Symfony\Component\RemoteEvent\Attribute\AsRemoteEventConsumer(name: 'sendgrid')] class SendGridConsumer implements ConsumerInterface { public function consume(RemoteEvent|MailerDeliveryEvent $event): void { // your code } }
Suppression Groups
Create an e-mail and add the SuppressionGroupHeader:
use Symfony\Component\Mailer\Bridge\Sendgrid\Header\SuppressionGroupHeader; // [...] $email = new Email(); $email->getHeaders()->add(new SuppressionGroupHeader(GROUP_ID, GROUPS_TO_DISPLAY));
where:
GROUP_IDis your Sendgrid suppression group IDGROUPS_TO_DISPLAY_IDis an array of the Sendgrid suppression group IDs presented to the user
Scheduling
When using the API transport (with a sendgrid+api DSN), you can schedule
your emails by providing a \DateTimeInterface object in a
Symfony\Component\Mime\Header\DateHeader named Send-At.
$email = new \Symfony\Component\Mime\Email(); $email->getHeaders()->addDateHeader('Send-At', new \DateTimeImmutable('+3 hours'));
It will be mapped to the send_at parameter of the [POST] /mail/send
API endpoint
Sponsor
This package is looking for a backer.
Help Symfony by sponsoring its development!