Skip to content

Commit

Permalink
feature #53554 [Mailer] Add Resend bridge (welcoMattic)
Browse files Browse the repository at this point in the history
This PR was merged into the 7.1 branch.

Discussion
----------

[Mailer] Add Resend bridge

| Q             | A
| ------------- | ---
| Branch?       | 7.1
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Issues        |
| License       | MIT
| Doc PR        | symfony/symfony-docs#19432
| Recipe        | symfony/recipes#1283

This PR adds a new Mailer bridge for [Resend](https://resend.com/).
In addition, it handles the webhooks sent by Resend for various events (sent, delivered, delivery_delayed, bounced, clicked, opened, complained).

The bridge and webhooks has been tested in a real 7.1 project (I can provide the reproducer if anyone want to test it).

Thanks to `@zenorocha` and all the Resend team for this tool!

NB: Docs PR will land later this week

Commits
-------

df72253350 Add Resend Mailer bridge
  • Loading branch information
fabpot committed Jan 18, 2024
2 parents 14b251e + f26cb41 commit 28e9731
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions DependencyInjection/FrameworkExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2572,6 +2572,7 @@ private function registerMailerConfiguration(array $config, ContainerBuilder $co
MailerBridge\MailPace\Transport\MailPaceTransportFactory::class => 'mailer.transport_factory.mailpace',
MailerBridge\Mailchimp\Transport\MandrillTransportFactory::class => 'mailer.transport_factory.mailchimp',
MailerBridge\Postmark\Transport\PostmarkTransportFactory::class => 'mailer.transport_factory.postmark',
MailerBridge\Resend\Transport\ResendTransportFactory::class => 'mailer.transport_factory.resend',
MailerBridge\Scaleway\Transport\ScalewayTransportFactory::class => 'mailer.transport_factory.scaleway',
MailerBridge\Sendgrid\Transport\SendgridTransportFactory::class => 'mailer.transport_factory.sendgrid',
MailerBridge\Amazon\Transport\SesTransportFactory::class => 'mailer.transport_factory.amazon',
Expand All @@ -2591,6 +2592,7 @@ private function registerMailerConfiguration(array $config, ContainerBuilder $co
MailerBridge\Mailgun\Webhook\MailgunRequestParser::class => 'mailer.webhook.request_parser.mailgun',
MailerBridge\Mailjet\Webhook\MailjetRequestParser::class => 'mailer.webhook.request_parser.mailjet',
MailerBridge\Postmark\Webhook\PostmarkRequestParser::class => 'mailer.webhook.request_parser.postmark',
MailerBridge\Resend\Webhook\ResendRequestParser::class => 'mailer.webhook.request_parser.resend',
MailerBridge\Sendgrid\Webhook\SendgridRequestParser::class => 'mailer.webhook.request_parser.sendgrid',
];

Expand Down
2 changes: 2 additions & 0 deletions Resources/config/mailer_transports.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Symfony\Component\Mailer\Bridge\Mailjet\Transport\MailjetTransportFactory;
use Symfony\Component\Mailer\Bridge\MailPace\Transport\MailPaceTransportFactory;
use Symfony\Component\Mailer\Bridge\Postmark\Transport\PostmarkTransportFactory;
use Symfony\Component\Mailer\Bridge\Resend\Transport\ResendTransportFactory;
use Symfony\Component\Mailer\Bridge\Scaleway\Transport\ScalewayTransportFactory;
use Symfony\Component\Mailer\Bridge\Sendgrid\Transport\SendgridTransportFactory;
use Symfony\Component\Mailer\Transport\AbstractTransportFactory;
Expand Down Expand Up @@ -55,6 +56,7 @@
'native' => NativeTransportFactory::class,
'null' => NullTransportFactory::class,
'postmark' => PostmarkTransportFactory::class,
'resend' => ResendTransportFactory::class,
'scaleway' => ScalewayTransportFactory::class,
'sendgrid' => SendgridTransportFactory::class,
'sendmail' => SendmailTransportFactory::class,
Expand Down
7 changes: 7 additions & 0 deletions Resources/config/mailer_webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
use Symfony\Component\Mailer\Bridge\Mailjet\Webhook\MailjetRequestParser;
use Symfony\Component\Mailer\Bridge\Postmark\RemoteEvent\PostmarkPayloadConverter;
use Symfony\Component\Mailer\Bridge\Postmark\Webhook\PostmarkRequestParser;
use Symfony\Component\Mailer\Bridge\Resend\RemoteEvent\ResendPayloadConverter;
use Symfony\Component\Mailer\Bridge\Resend\Webhook\ResendRequestParser;
use Symfony\Component\Mailer\Bridge\Sendgrid\RemoteEvent\SendgridPayloadConverter;
use Symfony\Component\Mailer\Bridge\Sendgrid\Webhook\SendgridRequestParser;

Expand All @@ -44,6 +46,11 @@
->args([service('mailer.payload_converter.postmark')])
->alias(PostmarkRequestParser::class, 'mailer.webhook.request_parser.postmark')

->set('mailer.payload_converter.resend', ResendPayloadConverter::class)
->set('mailer.webhook.request_parser.resend', ResendRequestParser::class)
->args([service('mailer.payload_converter.resend')])
->alias(ResendRequestParser::class, 'mailer.webhook.request_parser.resend')

->set('mailer.payload_converter.sendgrid', SendgridPayloadConverter::class)
->set('mailer.webhook.request_parser.sendgrid', SendgridRequestParser::class)
->args([service('mailer.payload_converter.sendgrid')])
Expand Down

0 comments on commit 28e9731

Please sign in to comment.