feat: add NeverBounce email verification for transactional emails#1499
Open
evanjacobson wants to merge 5 commits intomainfrom
Open
feat: add NeverBounce email verification for transactional emails#1499evanjacobson wants to merge 5 commits intomainfrom
evanjacobson wants to merge 5 commits intomainfrom
Conversation
Adds pre-send NeverBounce verification to reduce ~3% bounce rate on transactional emails. Blocks invalid and disposable emails; allows valid, catchall, and unknown through. Fails open if NeverBounce is unavailable. Callers receive SendResult so they can react to blocked emails: - Magic link route returns 400 with user-facing error - Org invite expires invitation row and throws BAD_REQUEST - Billing lifecycle cron removes idempotency row for retry - Admin email testing routes through send() for verification
4 tasks
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (2 files)
Reviewed by gpt-5.4-20260305 · 145,455 tokens |
- Admin sendTest restores original provider-specific routing (respects selected provider) with NeverBounce check added before dispatch - send() now checks provider return value — returns provider_not_configured when credentials are missing instead of falsely claiming sent: true - SendResult reason union extended with 'provider_not_configured'
evanjacobson
commented
Mar 24, 2026
Contributor
Author
There was a problem hiding this comment.
most of this will be filtered out after #1356 merges
17 tasks
- Magic link route: neverbounce_rejected → 400 (user's email is bad), provider_not_configured → 500 (server issue, don't blame the user) - Billing cron: only deletes idempotency row for provider_not_configured (transient). Keeps the row for neverbounce_rejected (terminal) to avoid re-verifying the same invalid address every sweep.
evanjacobson
commented
Mar 24, 2026
| execution_time: number; | ||
| }; | ||
|
|
||
| const BLOCKED_RESULTS = new Set<NeverBounceResult>(['invalid', 'disposable']); |
Contributor
Author
There was a problem hiding this comment.
note that 'disposable' was not explicitly included in the spec, but is included here. 'disposable' emails are services such as tempmail, guerilla mail, etc.
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.
Summary
Adds NeverBounce email verification before sending transactional emails to reduce our ~3% bounce rate. Blocks
invalidanddisposableemails; allowsvalid,catchall,unknownthrough. Fails open if NeverBounce is unavailable.How it works:
src/lib/email-neverbounce.tscalls the NeverBounce single-check API with a 5s timeoutsend()returnsSendResult({ sent: true } | { sent: false, reason }) so callers can reactCaller handling:
BAD_REQUESTsend()so NeverBounce is exercisedVerification
Automated tests (50 passing)
npx tsc --noEmit— no type errorspnpm lint— cleanemail-neverbounce.test.ts— 11 tests (all result types, fail-open, Sentry reporting, timeout, params)magic-link/route.test.ts— 10 testsautoTopUp.test.ts— 16 testsemail.test.ts— 13 testsManual tests (all passing on localhost)
fakeperson@xyznotarealdomainever.comtld→ HTTP 400test@mailinator.com→ HTTP 400support@neverbounce.com→ HTTP 200evan@kilocode.ai→ email received in inboxVisual Changes
N/A — no UI changes in this PR (admin page provider selector is unchanged).
Reviewer Notes
NEVERBOUNCE_API_KEYhas been added to Vercel.