Skip to content

feat(twilio): emulate SendGrid mail with Gmail inspection - #226

Closed
kamal wants to merge 3 commits into
vercel-labs:mainfrom
envoy:codex/sendgrid-emulation
Closed

feat(twilio): emulate SendGrid mail with Gmail inspection#226
kamal wants to merge 3 commits into
vercel-labs:mainfrom
envoy:codex/sendgrid-emulation

Conversation

@kamal

@kamal kamal commented Sep 4, 2026

Copy link
Copy Markdown

Summary

Applications can send email through their existing SendGrid clients and inspect the captured mail through the Google emulator's Gmail API, without a separate SMTP inbox service.

This extends the Twilio plugin rather than introducing a second email provider.

Design and limits

  • SendGrid Bearer keys are separate from Twilio Basic authentication.
  • Gmail delivery is opt-in. Without it, requests are captured in the Twilio store.
  • One configured Gmail mailbox captures all recipients, including BCC. This is a test inbox, not real recipient routing.
  • Gmail import failure returns 502. Multiple personalizations are not transactional; retries can duplicate earlier successful imports.
  • Templates and scheduled sends return 501. This is a Mail Send subset, not full SendGrid emulation.

The official Node SDK resets its base URL in setApiKey(), so configure the local endpoint afterward.

HEAD metadata compatibility

The shared HTTP layer now finalizes HEAD responses with a null body while preserving response and middleware headers. An empty streamed body caused Bun to replace Content-Length with chunked encoding, leaving Ruby S3 download clients without the file size they need.

The fix applies with and without middleware and cancels any discarded response stream. It is separate from the earlier S3 binary-object work, which is not included in this PR.

Validation

  • 41 Twilio tests passed, including the official SendGrid SDK over a loopback HTTP server.
  • Cross-emulator tests send into the real Google plugin, search by recipient and subject, read HTML and CC/BCC/reply-to headers, and retrieve binary attachment bytes.
  • Negative coverage includes authentication, malformed requests, sandbox non-delivery, unsupported features, and HTTP/network import failures.
  • Twilio typecheck, lint, and build passed.
  • All 78 core tests pass, including HEAD regressions that assert Content-Length and a null body with and without middleware, using a request with partNumber=1.
  • Core typecheck passes; lint reports no errors and 2 existing unused-symbol warnings. The latest core checks ran under Node 22; the repository declares Node 24 or newer.

Compound Engineering
Codex

@vercel

vercel Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

@kamal is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

@socket-security

socket-security Bot commented Sep 4, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​types/​nodemailer@​8.0.11001007687100
Addednpm/​@​sendgrid/​client@​8.1.610010010081100
Addednpm/​@​sendgrid/​mail@​8.1.610010010081100
Addednpm/​nodemailer@​9.1.1961009795100

View full report

@kamal kamal closed this Sep 4, 2026
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.

1 participant