Repository navigation
Conversation
Add a `MAIL_PROVIDER` switch (default `smtp`, behavior unchanged) that
routes `sendEmail` through the MailKite API via the
`nodemailer-mailkite-transport` package when set to `mailkite`. It reuses
the same nodemailer-based path the kit already uses for SMTP, so every
existing sender (magic link, verification, password reset, team invite,
welcome) works unchanged.
- lib/env.ts: add `mailProvider` + `mailkite.{apiKey,baseUrl}` config
- lib/email/sendEmail.ts: select transport by provider; keep the
no-op-when-unconfigured dev guard for both providers
- .env.example: document MAIL_PROVIDER / MAILKITE_API_KEY / MAILKITE_BASE_URL
- lib/email/sendEmail.test.ts: unit tests for provider selection
- package.json: add nodemailer-mailkite-transport (peer nodemailer >=6)
|
Someone is attempting to deploy a commit to the BoxyHQ Team on Vercel. A member of the Team first needs to authorize it. |
Author
|
👋 Gentle bump on this — it's been ~2 weeks and is still mergeable. The only outstanding check is the Vercel fork-deploy authorization (needs a BoxHQ team member). Happy to rebase, address any review feedback, or adjust the docs table if that helps get it in. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this adds
An alternative email provider alongside SMTP: when
MAIL_PROVIDER=mailkite,sendEmail()sends through the MailKite API instead of an SMTP server. It reuses the exact nodemailer-based path the kit already uses for SMTP, so every existing sender (sendMagicLink,sendVerificationEmail,sendPasswordResetEmail,sendTeamInviteEmail,sendWelcomeEmail) works unchanged — no call-site changes.MailKite is a developer email platform (inbound parsing via webhooks + transactional send). Some users prefer an API key over standing up an SMTP server, especially for magic-link / verification mail where deliverability matters and an API gives per-message tracking out of the box.
How to configure
.env.example:SMTP_FROMis reused as the defaultfromfor both providers, so nothing else changes for existing users.Backward compatibility
MAIL_PROVIDERdefaults tosmtp→ the transporter, theif (!SMTP_HOST) returndev guard, and all send behaviour are byte-for-byte unchanged when unset.MAIL_PROVIDER=mailkitebut no key is set (e.g. local dev),sendEmailno-ops, mirroring the existing "no SMTP host" behaviour, so the app still boots.How I tested it
Locally against a fresh clone of
main:lib/email/sendEmail.test.tsis the repo's first unit test; it covers provider selection (MailKite with/without key, custom base URL, SMTP default with/without host) by mockingnodemailerand the transport, so it asserts wiring without network. Jest already runs in CI (npm run testin.github/workflows/main.yml), so these will execute on this PR.Note on
package-lock.json: I intentionally did not commit it — my local npm (v11) dedupes the tree differently and would produce a ~2000-line churn unrelated to this change. Your CI runsnpm install(notnpm ci), which will add the new entry cleanly. Happy to regenerate it if you'd prefer a committed lockfile.Disclosure
I work on MailKite, so I have an obvious interest in seeing it supported here — but the goal is a genuinely useful, maintained provider that fits the kit's existing patterns, not a drive-by. If a second mail provider isn't something you want to carry, no worries at all. If it is, I'm happy to maintain the integration (track nodemailer/Wasp/Next updates, keep tests green) and adjust the implementation to match whatever shape you'd prefer.
Closes nothing — opening for discussion; happy to refactor.