Node.js

Mailtrap Node.js SDK on GitHub

Overview

Mailtrap can be integrated with Node.js apps for email sending purposes with SDK, SMTP, and RESTful API.

Email API/SMTP for Node.js

SDK integration

The Mailtrap Node.js SDK provides a simple and intuitive way to send transactional and bulk emails from your Node.js applications. The SDK supports:

  • Transactional email sending

  • Batch email sending

  • Template management

  • Contact management

  • Sandbox testing

  • Account management

Installation

Install the SDK using npm or yarn:

Minimal Example

Here's a minimal example to send your first email:

Get your API token from your Mailtrap account under Settings → API Tokens.

SMTP integration

To integrate SMTP with your Node.js app, navigate to the Integration tab under Sending Domains and copy/paste the ready-made code snippet or credentials.

You'll have to use Nodemailer, as Node.js doesn't have built-in support for SMTP sending.

Read more about SMTP integration in the Email API/SMTP - SMTP Integration article.

RESTful API integration

To integrate Mailtrap using RESTful API, use the sample configuration among Code samples under the API section.

API integration can be used with any Node.js framework or library that supports HTTP requests. For more details, refer to the API documentation.

Read more about API integration in the Email API/SMTP - API Integration article.

Last updated

Was this helpful?