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

add support for sending emails with resend.com #1248

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

Conversation

mscno
Copy link

@mscno mscno commented Jan 30, 2025

#1247

This PR introduces support for Resend.com as an email provider, alongside existing AWS SES and Mailgun implementations. It allows users to configure Resend as their email service and send emails using Resend’s API.

Changes Introduced
• Added a new resend package implementing the email.Service interface.
• Integrated Resend Go SDK (github.com/resend/resend-go/v2) for email sending.
• Implemented sendMail function to send emails via Resend.
• Added basic tagging support (template and tenant tags) for tracking emails.
• Registered the service via bus.Register(Service{}), allowing dynamic configuration.
• Stubbed out fetchRecentSuppressions, as Resend does not provide an API for fetching suppressed addresses directly.

Implementation Details
• Uses resend.NewClient to initialize the Resend API client.
• Emails are sent with a subject, HTML body, and recipient list.
• Logs debug messages for email sending and failures.
• Handles missing sender/recipient addresses and ensures emails can be sent.

Next Steps
• Implement webhook-based suppression handling for tracking bounced emails.
• Improve error handling and add retries for transient failures.

Why This Change?

This change expands email provider support, allowing users to choose Resend as a more developer-friendly and modern alternative to AWS SES or Mailgun.

@mattwoberts mattwoberts self-requested a review January 31, 2025 08:14
Copy link
Contributor

@mattwoberts mattwoberts left a comment

Choose a reason for hiding this comment

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

Hey @mscno

Many thanks. This looks good, can't spot any issues with it at all :)

Implement webhook-based suppression handling for tracking bounced emails.

So in resend you need to keep track of bounced emails sent to a webhook? We can make it work that way, it's just a bit more work to track.

Improve error handling and add retries for transient failures.

Yes a retry mechanism for all email sending would be quite good to have, agreed. It might be better to take that as a separate piece of work / PR though if we did look at that.

@mscno
Copy link
Author

mscno commented Jan 31, 2025

Resend doesnt have a suppresion API like AWS so for now.

So for now I just return nil and dont set any suppressed emails.

The only way to make it work is to manually listen to bounce webhooks from resend and then store these somehow. Probably this is a little too much work, for what its worth.

Its not strictly necessary to have the suppressed emails I think.

Agreed that the retry mechanism is probably better handled in the email service level rather than on the level of each provider.

@mscno mscno changed the title add support for sending emails with resend.dev add support for sending emails with resend.com Jan 31, 2025
@mattwoberts
Copy link
Contributor

The only way to make it work is to manually listen to bounce webhooks from resend and then store these somehow. Probably this is a little too much work, for what its worth.

Yeah I think I agree, there's a lot of effort there to get the bounces to be processed like the others. I think we're OK to leave this.

@mattwoberts
Copy link
Contributor

Hey @mscno

Ok I'm happy to bring this into main, I think the only thing we're missing here is some bit of update to the docs to let people know that resend is an option - https://github.com/getfider/fider-documentation/blob/main/docs/self-hosted/hosting-instance.mdx

@mscno
Copy link
Author

mscno commented Feb 6, 2025

added here

getfider/fider-documentation#1

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.

2 participants