Skip to content

Support HTTP API email providers (SendGrid, Resend, ...) for self-hosting #6976

Description

@ksk-ktsr

Problem

Self-hosted Nango can only send transactional email (verification, invites, usage notifications) through Mailgun's API or SMTP:

// packages/email/lib/client.ts
if (envs.MAILGUN_API_KEY) {
    this.provider = new MailgunEmailProvider();
} else if (envs.SMTP_URL) {
    this.provider = new SmtpEmailProvider();
} else {
    this.provider = new NoEmailProvider();
}

In deployments where outbound SMTP is blocked and Mailgun isn't the vendor of choice, there is no working configuration. NoEmailProvider only logs, so those emails are silently never delivered.

Proposal

Add a generic HTTP provider implementing the existing EmailProvider<T> interface, configured entirely by env vars, so any JSON-over-HTTP mail API (SendGrid, Resend, Postmark, ...) can be used without a vendor-specific module. No new dependency is needed — fetch is built in on the supported Node (>= 20), unlike the Mailgun path which pulls mailgun.js + form-data.

Rough shape:

EMAIL_HTTP_URL=https://api.sendgrid.com/v3/mail/send
EMAIL_HTTP_HEADERS={"Authorization":"Bearer <key>"}
EMAIL_HTTP_BODY=<JSON template with {{to}} / {{from}} / {{subject}} / {{html}}>

Selection would slot into the existing precedence chain after SMTP, so behaviour is unchanged for anyone already configured.

Questions before I open a PR

  1. Is a generic template-driven provider the direction you'd want, or would you rather see a vendor-specific SendGridEmailProvider sitting next to MailgunEmailProvider?
  2. packages/email has no tests today (vitest is already a devDependency). I'd add the first ones covering this provider — any objection?

Happy to send the PR once you confirm the direction.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions