Email infrastructure guide
Email API with Node.js
A server-side pattern for sending transactional email from Node.js without leaking API keys.
Node.js applications should keep email sending behind a server-side module or job worker. The module receives a validated message request, calls the email API, and persists the provider response for observability.
What this means in practice
- Server-only API credentials
- Input validation before sends
- Timeout and retry policy
- Stored message identifiers for support and audit
Implementation checklist
- Read the API key from a server environment variable.
- Validate sender, recipient, subject, and content fields.
- Call the email API from a service module or queue worker.
- Store the returned message ID with the product event.
- Retry only failures that are known to be transient.
Questions teams ask
Can I call an email API from browser JavaScript?
Do not expose a sending API key in browser code. Send through your Node.js backend instead.
Should email sending block a web request?
For critical actions it can, but queues are often better for retries and resilience.