Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add resend provider #28

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

danielhe4rt
Copy link

This pull request introduces a new email driver for the Resend service, updates the mail provider manager to include the new driver, and adds tests to verify the functionality of the Resend driver.

One of the issues may be the creation of a Webhook, however you can create it manually. I still need to do some research on it, but probably it will turn into a future update.

Key Features:

  • src/Drivers/ResendDriver.php: Introduced the ResendDriver class implementing MailDriverContract, with methods for registering webhooks, verifying webhook signatures, extracting UUIDs and timestamps from payloads, and mapping events and data.
  • tests/ResendTest.php: Added multiple tests to verify the Resend driver's ability to handle various webhook events, including delivery, hard bounce, soft bounce, complaint, open, and click events.

Copy link
Member

@markvaneijk markvaneijk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small things to pick up before adding this feature.

@@ -20,6 +21,8 @@ public function __invoke(Request $request, string $driver): Response
return response('Invalid signature.', status: 400);
}

Log::channel('single')->log('info', 'Webhook received', $request->all());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed.

{
public function registerWebhooks($components): void
{
// TODO: verify if we can hack the user endpoint to create a webhook
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Display a console info message using $components with webhook URL and the link to add this to Resend (https://resend.com/webhooks)

EventType::HARD_BOUNCED->value => ['type' => 'email.bounced'],
EventType::OPENED->value => ['type' => 'email.opened'],
EventType::SOFT_BOUNCED->value => ['type' => 'email.delivery_delayed'],
EventType::UNSUBSCRIBED->value => ['type' => 'SubscriptionChange'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed if Resend does not have a subscribed event.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants