@sendgrid/mail

Official Node.js SDK for sending transactional and marketing email through the Twilio SendGrid API.

SDK
npm
v8.1.6
3,054stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
66/100Good
Development Activity28
Maintenance44
Community92
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
76/100Good
Architecture78
Code Quality76
Innovation60
Learning Curve88

@sendgrid/mail is Twilio SendGrid’s dedicated Node.js client for the mail-sending endpoint of the SendGrid v3 Web API. It provides a small, focused API — setApiKey() plus send()/sendMultiple() — for constructing and dispatching transactional or marketing email, including HTML/text bodies, attachments, templates, personalization, and scheduled sends, without requiring consumers to hand-build HTTP requests against the SendGrid REST API.

The package is one of several published from the sendgrid-nodejs monorepo, which also includes @sendgrid/client (for calling the rest of SendGrid’s v3 API beyond mail), @sendgrid/eventwebhook (webhook signature verification), and @sendgrid/inbound-mail-parser. @sendgrid/mail is the entry point the SendGrid documentation recommends for the most common use case — sending email — and depends internally on @sendgrid/client for the underlying HTTP transport.

What You Get

  • setApiKey() and send()/sendMultiple() methods for dispatching one or many emails via the SendGrid v3 mail-send endpoint
  • Support for HTML and plain-text bodies, file attachments, CC/BCC, custom headers, and categories on a single message object
  • Dynamic template support for SendGrid’s transactional templates, with per-recipient personalization substitutions
  • Scheduled sends (sendAt) and batch IDs for coordinating and later canceling groups of scheduled emails
  • Built-in retry-friendly error objects surfacing SendGrid API response codes and body details for debugging failed sends
  • TypeScript type definitions (mail.d.ts) describing the message payload shape

Common Use Cases

  • Sending transactional emails — password resets, order confirmations, welcome emails — from a Node.js backend or serverless function
  • Triggering marketing or lifecycle email campaigns using SendGrid dynamic templates with per-user personalization
  • Batch-sending emails to many recipients in a single API call via sendMultiple()
  • Scheduling emails for future delivery and canceling scheduled batches through the sendAt/batch-id workflow
  • Attaching generated documents (invoices, receipts) to outbound email without managing raw MIME encoding

Under The Hood

Architecture - @sendgrid/mail (packages/mail/src/mail.js) is a thin façade over @sendgrid/client, which performs the actual authenticated HTTP requests to the SendGrid v3 API; @sendgrid/mail is responsible for validating and normalizing the message object (recipients, content, attachments, personalizations) via helper classes from the shared @sendgrid/helpers package before handing the request off to the client package’s request() method. This layering is what lets the monorepo publish a narrow @sendgrid/mail package for the common case while @sendgrid/client remains available separately for the full breadth of SendGrid’s API surface (contacts, stats, templates management, etc.).

Tech Stack - Written in JavaScript with accompanying TypeScript declaration files, structured as an npm/Lerna-style monorepo workspace where packages/mail depends on the sibling packages/client and packages/helpers via workspace references rather than published npm versions during development. Node.js 10+ is required per the package’s engines field, with no other runtime dependencies beyond its sibling SendGrid packages.

Code Quality - mail.spec.js sits alongside the implementation file under packages/mail/src, and the monorepo’s CI (historically Travis CI, referenced in the README badge) runs the shared test suite across all packages. The library has a documented breaking-change migration guide (v6 to v7) in docs/migration-guides/, showing an established process for communicating API changes to consumers rather than silent breaking releases.

API Design - The two-call quick start (setApiKey() then send()) is deliberately minimal for the common transactional-email case, and the message object’s field names map closely to the underlying SendGrid v3 API JSON schema, so developers reading SendGrid’s REST API docs can apply that knowledge directly to the Node.js message object. The tradeoff is that anything outside mail sending — managing contacts, templates, or stats — requires switching to the separate @sendgrid/client package, which has a lower-level, more general request-based API.

Used by 13 apps in this directory

TypeScript
96%
Other

Amplication

Developer Tools · AI Code Assistants · Automation

16,010

Create production-ready backend services with your organization's standards baked in — generating NestJS, Prisma, and GraphQL code that you own and control.

View details
61
Repo Health
84
Technical
60
Dependency
Built with
TypeScript96%
Updated 1 months ago
TypeScript
100%
MIT

Botpress

AI Assistants · AI Development · Customer Support

14,872

The open-source hub for building and deploying LLM-powered AI agents with TypeScript-first tooling, 40+ integrations, and a revolutionary code-execution agent framework.

View details
95
Repo Health
82
Technical
66
Dependency
Built with
TypeScript100%
Updated yesterday
TypeScript
45%
Other

Convex Backend

Developer Tools · Databases

12,394

Open-source reactive database that lets developers build live-updating apps with pure TypeScript, strong consistency, and real-time subscriptions—no separate API layer required.

View details
88
Repo Health
82
Technical
70
Dependency
Built with
TypeScript45%
Rust43%
Updated today
TypeScript
92%
MIT

Dittofeed

Marketing · Automation

2,903

Open-source omni-channel customer engagement platform for automating transactional and marketing messages via email, SMS, WhatsApp, Slack, and mobile push.

View details
54
Repo Health
75
Technical
63
Dependency
Built with
TypeScript92%
Updated 4 months ago
TypeScript
94%
AGPL 3.0

Laudspeaker

Marketing · Automation

2,618

Open-source customer engagement platform for building visual, event-triggered messaging journeys across email, SMS, push, in-app, and webhooks.

View details
53
Repo Health
66
Technical
64
Dependency
Built with
TypeScript94%
Updated 1 months ago
TypeScript
86%
MIT

medusa

Ecommerce

35,900

The most flexible open-source commerce platform — build B2C, B2B, and marketplace applications with modular, composable commerce primitives.

View details
94
Repo Health
87
Technical
65
Dependency
Built with
TypeScript86%
JavaScript14%
Updated today
TypeScript
98%
Other

Novu

Developer Tools

39,615

Open-source communication infrastructure that connects your products and AI agents to every channel your users live on — Inbox, Email, SMS, Push, Chat, and more.

View details
93
Repo Health
80
Technical
65
Dependency
Built with
TypeScript98%
Updated today
TypeScript
27%
AGPL 3.0

Omnivore

Knowledge Management · Bookmarks Archiving · Note Taking

16,221

Self-hosted read-it-later platform with highlights, newsletters, PDFs, and seamless Obsidian and Logseq integration.

View details
78
Repo Health
74
Technical
66
Dependency
Built with
TypeScript27%
JavaScript24%
HTML19%
Updated 2 days ago
TypeScript
92%
Apache 2.0

OneUptime

Monitoring

7,481

The complete open-source observability platform that replaces PagerDuty, Datadog, Sentry, and StatusPage with a single self-hostable system.

View details
90
Repo Health
81
Technical
66
Dependency
Built with
TypeScript92%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search