Why Nodemailer? Node.js doesn’t have built-in SMTP support, but Nodemailer provides a powerful, well-maintained solution with extensive features including HTML emails, attachments, embedded images, and robust error handling.
Prerequisites
Before sending, verify your domain and create an SMTP credential. Use a sandbox credential for these examples so no email is delivered. Keep the username and password in your server’s secret store. Before you begin, ensure you have:System Requirements
System Requirements
- Node.js installed on your system (Download Node.js)
- npm or yarn package manager
- Basic knowledge of JavaScript and Node.js
Installation
Install Nodemailer in your Node.js project:TypeScript Support
Connection Settings
All message data is stored in the EU. See SMTP limits.
Basic Email Examples
Testing with Sandbox Mode
Use sandbox mode to safely test your Node.js email integration:Sandbox Benefits: Emails sent in sandbox mode are free, trigger webhooks normally, and never actually deliver to recipients - perfect for development and testing.
Environment Variables & Best Practices
Using Environment Variables
Resources
Nodemailer Documentation
Official Nodemailer documentation and examples
AhaSend Support
Get help from our engineering team
Related Guides
- Before sending: verify your domain and create an SMTP credential.
- Connection and message rules: SMTP hosts, ports and limits, special headers, sandbox mode, retention and plan features.
- Other ways to send: REST API, AhaSend CLI, Node.js SDK and Go SDK.
- Delivery events: webhook setup and local webhook testing.

