mailgun-js vs nodemailer vs sendgrid
Node.js 環境におけるメール送信ライブラリの選定と実装
mailgun-jsnodemailersendgrid類似パッケージ:

Node.js 環境におけるメール送信ライブラリの選定と実装

mailgun-jsnodemailersendgrid は、Node.js アプリケーションからメールを送信するための代表的なライブラリです。nodemailer は SMTP プロトコルを通じてあらゆるメールサーバーと連携できる汎用ライブラリであり、mailgun-jssendgrid はそれぞれ Mailgun 社と SendGrid 社の API に特化した公式 SDK です。これらはメール配信の信頼性、設定の簡易さ、そして依存するインフラストラクチャにおいて異なるアプローチを取ります。

npmのダウンロードトレンド

3 年

GitHub Starsランキング

統計詳細

パッケージ
ダウンロード数
Stars
サイズ
Issues
公開日時
ライセンス
mailgun-js0892-528年前MIT
nodemailer017,560543 kB020日前MIT-0
sendgrid03,052-939年前MIT

Node.js メール送信ライブラリ比較:mailgun-js vs nodemailer vs sendgrid

Node.js でメール機能を実装する際、mailgun-jsnodemailersendgrid の 3 つが主要な選択肢として挙げられます。しかし、これらは根本的に役割が異なります。nodemailer は SMTP クライアントとして動作する汎用ライブラリであり、mailgun-jssendgrid は特定のメール配信サービス(ESP)の API を叩くための SDK です。実装の容易さ、保守性、そして配信の信頼性を考慮し、技術的な違いを詳しく見ていきましょう。

⚠️ 保守状況とパッケージの選定

まず最重要な点として、mailgun-js の現状を理解する必要があります。

mailgun-js は公式に非推奨(deprecated)となっています。メンテナンスが停止しており、セキュリティアップデートも期待できません。

// mailgun-js: 非推奨パッケージ(使用すべきではない)
const mailgun = require('mailgun-js');
const mg = mailgun({ apiKey: process.env.MAILGUN_API_KEY, domain: 'example.com' });
// ⚠️ 新規プロジェクトでは mailgun.js へ移行すべき

後継の mailgun.js へ移行するのが正解ですが、比較対象として挙がっているため、ここでは「使うべきではない」という前提で扱います。

nodemailer は長年にわたりメンテナンスされており、SMTP 接続のデファクトスタンダードです。

// nodemailer: 活発にメンテナンスされている
const nodemailer = require('nodemailer');
const transporter = nodemailer.createTransport({
  host: 'smtp.example.com',
  port: 587,
  secure: false,
  auth: { user: 'user', pass: 'pass' }
});

sendgrid (正確には @sendgrid/mail)も SendGrid 社によって公式に維持されており、API 経由での送信に特化しています。

// sendgrid: 公式 SDK として維持されている
const sgMail = require('@sendgrid/mail');
sgMail.setApiKey(process.env.SENDGRID_API_KEY);

📡 通信プロトコル:SMTP vs REST API

メールを送る仕組みがライブラリによって全く異なります。

nodemailerSMTP プロトコルを使用します。これはメールサーバーと直接通信する伝統的な方法です。

// nodemailer: SMTP 接続を確立して送信
await transporter.sendMail({
  from: '"Tester" <test@example.com>',
  to: 'recipient@example.com',
  subject: 'SMTP Test',
  text: 'Hello via SMTP'
});

sendgridHTTP REST API を使用します。メールデータを JSON として API エンドポイントに送信します。

// sendgrid: HTTPS API 経由で送信
await sgMail.send({
  to: 'recipient@example.com',
  from: 'sender@yourdomain.com',
  subject: 'API Test',
  text: 'Hello via API'
});

mailgun-jsHTTP REST API を使用していましたが、前述の通り非推奨です。

// mailgun-js: HTTPS API 経由(非推奨)
mg.messages().send({
  from: 'Excited User <mail@example.com>',
  to: ['recipient@example.com'],
  subject: 'Deprecated API',
  text: 'Do not use this package'
});

🔐 認証と設定の管理

認証情報の扱いもアーキテクチャに影響します。

nodemailer は SMTP サーバーの認証情報(ユーザー名とパスワード)が必要です。Gmail などはアプリパスワードの生成が必要です。

// nodemailer: SMTP 認証情報
const transporter = nodemailer.createTransport({
  service: 'gmail',
  auth: {
    user: 'myemail@gmail.com',
    pass: 'app_password_here'
  }
});

sendgrid は API 鍵のみを設定します。SMTP 認証は不要で、ファイアウォール設定などもシンプルです。

// sendgrid: API 鍵のみ
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
// 追加の設定は send 関数の引数で行う

mailgun-js は API 鍵とドメイン名を設定します。

// mailgun-js: API 鍵とドメイン
const mg = mailgun({
  apiKey: process.env.MAILGUN_API_KEY,
  domain: 'example.com'
});

📨 機能と拡張性:テンプレートと添付ファイル

実務で必要な機能の実装方法を比較します。

動的テンプレートの使用

sendgrid はクラウド上で管理されたテンプレート ID を指定して送信できます。これが最大の強みです。

// sendgrid: 管理画面で作ったテンプレート ID を使用
await sgMail.send({
  to: 'user@example.com',
  from: 'noreply@example.com',
  templateId: 'd-xxxxxxxxxxxx',
  dynamicTemplateData: { name: 'User' }
});

nodemailer はテンプレート機能を持っていません。handlebars などの外部ライブラリと組み合わせて HTML を生成する必要があります。

// nodemailer: 外部ライブラリでテンプレート処理が必要
const html = handlebars.compile(templateString)({ name: 'User' });
await transporter.sendMail({
  to: 'user@example.com',
  html: html
});

mailgun-js はテンプレート機能をサポートしていましたが、非推奨パッケージのため詳細は省略します。

// mailgun-js: template 変数で指定可能(非推奨)
mg.messages().send({
  to: ['user@example.com'],
  template: 'welcome',
  'h:X-Mailgun-Variables': JSON.stringify({ name: 'User' })
});

添付ファイルの処理

nodemailer はバッファやストリーム、パスなど柔軟に添付できます。

// nodemailer: 多様なソースから添付可能
await transporter.sendMail({
  attachments: [
    { filename: 'doc.pdf', path: '/path/to/file.pdf' },
    { filename: 'data.txt', content: Buffer.from('text') }
  ]
});

sendgrid は Base64 エンコードされたコンテンツを指定します。

// sendgrid: Base64 エンコードが必要
const attachment = {
  content: fs.readFileSync('doc.pdf').toString('base64'),
  filename: 'doc.pdf',
  type: 'application/pdf',
  disposition: 'attachment'
};
await sgMail.send({ attachments: [attachment] });

📊 配信分析と信頼性

メールが届いたかどうかの追跡機能は、サービス依存度が大きいです。

sendgrid は配信、オープン、クリックなどのイベントを Webhook で受け取れます。ライブラリ側で設定するわけではありませんが、サービスとして強力です。

// sendgrid: 管理画面や Event Webhook で分析
// コード側ではカテゴリを付与して分類可能
await sgMail.send({
  categories: ['transactional', 'welcome-flow']
});

nodemailer 単体では配信追跡機能はありません。SMTP サーバーがログを残すか、別途トラッキングピクセルなどを埋め込む必要があります。

// nodemailer: 標準では分析機能なし
// 自前でトラッキングリンクを生成するなどの工夫が必要

mailgun-js も Mailgun のダッシュボードを通じて分析できましたが、パッケージの非推奨化により将来性がありません。

🤝 共通点:Node.js メール送信の基盤

これら 3 つ(および後継の mailgun.js)には、Node.js でメールを扱う上での共通の基盤があります。

1. 🌍 環境変数による認証管理

  • すべて API 鍵やパスワード をコードに直接書かず、環境変数から読み取ることを推奨しています。
  • セキュリティリスクを避けるための基本的なプラクティスです。
// 共通:環境変数の使用
const apiKey = process.env.EMAIL_API_KEY;
const smtpPass = process.env.SMTP_PASSWORD;

2. 📨 非同期処理(Promise/async-await)

  • すべて 非同期処理 として設計されています。
  • async/await を使用してエラーハンドリングを行うのが一般的です。
// 共通:エラーハンドリング
try {
  await sendMailFunction();
} catch (error) {
  console.error('送信失敗:', error);
}

3. 📝 HTML とテキストのマルチパート

  • すべて HTML とプレーンテキスト の両方をサポートしています。
  • メールクライアントの互換性を高めるための標準機能です。
// 共通:マルチパート形式
const mailOptions = {
  text: 'Plain text version',
  html: '<strong>HTML version</strong>'
};

📊 比較サマリー

特徴mailgun-jsnodemailersendgrid
ステータス❌ 非推奨✅ 活発✅ 活発
プロトコルREST APISMTPREST API
プロバイダーMailgun任意 (Gmail, SES 等)SendGrid
テンプレート対応 (API)非対応 (外部併用)対応 (管理画面)
設定難易度高 (SMTP 設定)低 (API 鍵のみ)
配信分析ダッシュボード自前実装が必要ダッシュボード

💡 結論:どれを選ぶべきか

mailgun-js選んではいけません。非推奨パッケージであり、セキュリティリスクと将来の動作保証がないためです。Mailgun を使いたい場合は mailgun.js を使用してください。

nodemailer は、インフラの制御権を握りたい場合に最適です。AWS SES や自前 SMTP サーバーを使用し、コストを抑えつつ柔軟に設定を変更したいプロジェクトに向いています。ただし、配信最適化や分析機能は自分で構築する必要があります。

sendgrid は、開発スピードと配信信頼性を優先する場合に最適です。API 鍵を設定するだけですぐに使え、テンプレート管理や配信分析も最初から用意されています。スタートアップや、メール配信の運用コストを減らしたいチームに適しています。

最終的なアドバイス:新規プロジェクトでは mailgun-js を避け、nodemailer(汎用性重視)か sendgrid(機能性重視)のどちらかから選定しましょう。メール配信はアプリケーションの信頼性に直結するため、保守性が確保されたライブラリを選ぶことが重要です。

選び方: mailgun-js vs nodemailer vs sendgrid

  • mailgun-js:

    このパッケージは現在非推奨(deprecated)となっているため、新規プロジェクトでの使用は避けるべきです。Mailgun を利用する場合は、後継である mailgun.js への移行を検討してください。既存のレガシーコードのメンテナンス以外で選ぶ理由はありません。

  • nodemailer:

    特定のメールプロバイダーに依存せず、自前の SMTP サーバーや AWS SES、Gmail などを自由に切り替えたい場合に最適です。設定項目が多く柔軟性が高い一方、配信最適化や詳細な分析機能はプロバイダー側の実装に依存します。

  • sendgrid:

    SendGrid の API を利用して、高い配信到達率や詳細な分析機能、テンプレート管理を必要とする場合に適しています。API 鍵による認証が必須であり、SendGrid のサービス利用契約が必要ですが、トランザクショナルメールに特化した強力な機能を提供します。

mailgun-js のREADME

mailgun.js

Simple Node.js module for Mailgun.

npm version JavaScript Style Guide License Donate Buy me a coffee

Installation

npm install mailgun-js

Usage overview

This is a simple Node.js module for interacting with the Mailgun API. This module is intended to be used within Node.js environment and not from the browser. For browser use the mailgun.js module.

Please see Mailgun Documentation for full Mailgun API reference.

This module works by providing proxy objects for interacting with different resources through the Mailgun API. Most methods take a data parameter, which is a Javascript object that would contain the arguments for the Mailgun API. All methods take a final parameter callback with two parameters: error, and body. We try to parse the body into a javascript object, and return it to the callback as such for easier use and inspection by the client. If there was an error a new Error object will be passed to the callback in the error parameter. If the error originated from the (Mailgun) server, the response code will be available in the statusCode property of the error object passed in the callback. See the /docs folder for detailed documentation. For full usage examples see the /test folder.

var api_key = 'XXXXXXXXXXXXXXXXXXXXXXX';
var domain = 'www.mydomain.com';
var mailgun = require('mailgun-js')({apiKey: api_key, domain: domain});

var data = {
  from: 'Excited User <me@samples.mailgun.org>',
  to: 'serobnic@mail.ru',
  subject: 'Hello',
  text: 'Testing some Mailgun awesomeness!'
};

mailgun.messages().send(data, function (error, body) {
  console.log(body);
});

Note that the to field is required and should be a string containing 1 or more comma-separated addresses. Additionally cc and bcc fields can be specified. Recipients in those fields will be addressed as such. See https://documentation.mailgun.com/api-sending.html#sending for additional details.

Messages stored using the Mailgun store() action can be retrieved using messages(<message_key>).info() function. Optionally the MIME representation of the message can be retrieved if MIME argument is passed in and set to true.

Something more elaborate. Get mailing list info, create a member and get mailing list members and update member. Notice that the proxy objects can be reused.

var list = mailgun.lists('mylist@mycompany.com');

list.info(function (err, data) {
  // `data` is mailing list info
  console.log(data);
});

var bob = {
  subscribed: true,
  address: 'bob@gmail.com',
  name: 'Bob Bar',
  vars: {age: 26}
};

list.members().create(bob, function (err, data) {
  // `data` is the member details
  console.log(data);
});

list.members().list(function (err, members) {
  // `members` is the list of members
  console.log(members);
});

list.members('bob@gmail.com').update({ name: 'Foo Bar' }, function (err, body) {
  console.log(body);
});

list.members('bob@gmail.com').delete(function (err, data) {
  console.log(data);
});

Options

Mailgun object constructor options:

  • apiKey - Your Mailgun API KEY
  • publicApiKey - Your public Mailgun API KEY
  • domain - Your Mailgun Domain (Please note: domain field is MY-DOMAIN-NAME.com, not https://api.mailgun.net/v3/MY-DOMAIN-NAME.com)
  • mute - Set to true if you wish to mute the console error logs in validateWebhook() function
  • proxy - The proxy URI in format http[s]://[auth@]host:port. ex: 'http://proxy.example.com:8080'
  • timeout - Request timeout in milliseconds
  • host - the mailgun host (default: 'api.mailgun.net'). Note that if you are using the EU region the host should be set to 'api.eu.mailgun.net'
  • protocol - the mailgun protocol (default: 'https:', possible values: 'http:' or 'https:')
  • port - the mailgun port (default: '443')
  • endpoint - the mailgun host (default: '/v3')
  • retry - the number of total attempts to do when performing requests. Default is 1. That is, we will try an operation only once with no retries on error. You can also use a config object compatible with the async library for more control as to how the retries take place. See docs here
  • testMode - turn test mode on. If test mode is on, no requests are made, rather the request options and data is logged
  • testModeLogger - custom test mode logging function

Attachments

Attachments can be sent using either the attachment or inline parameters. inline parameter can be use to send an attachment with inline disposition. It can be used to send inline images. Both types are supported with same mechanisms as described, we will just use attachment parameter in the documentation below but same stands for inline.

Sending attachments can be done in a few ways. We can use the path to a file in the attachment parameter. If the attachment parameter is of type string it is assumed to be the path to a file.

var filepath = path.join(__dirname, 'mailgun_logo.png');

var data = {
  from: 'Excited User <me@samples.mailgun.org>',
  to: 'serobnic@mail.ru',
  subject: 'Hello',
  text: 'Testing some Mailgun awesomeness!',
  attachment: filepath
};

mailgun.messages().send(data, function (error, body) {
  console.log(body);
});

We can pass a buffer (has to be a Buffer object) of the data. If a buffer is used the data will be attached using a generic filename "file".

var filepath = path.join(__dirname, 'mailgun_logo.png');
var file = fs.readFileSync(filepath);

var data = {
  from: 'Excited User <me@samples.mailgun.org>',
  to: 'serobnic@mail.ru',
  subject: 'Hello',
  text: 'Testing some Mailgun awesomeness!',
  attachment: file
};

mailgun.messages().send(data, function (error, body) {
  console.log(body);
});

We can also pass in a stream of the data. This is useful if you're attaching a file from the internet.

var request = require('request');
var file = request("https://www.google.ca/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png");

var data = {
  from: 'Excited User <me@samples.mailgun.org>',
  to: 'serobnic@mail.ru',
  subject: 'Hello',
  text: 'Testing some Mailgun awesomeness!',
  attachment: file
};

mailgun.messages().send(data, function (error, body) {
  console.log(body);
});

Finally we provide a Mailgun.Attachment class to add attachments with a bit more customization. The Attachment constructor takes an options object. The options parameters can have the following fields:

  • data - can be one of
    • a string representing file path to the attachment
    • a buffer of file data
    • an instance of Stream which means it is a readable stream.
  • filename - the file name to be used for the attachment. Default is 'file'
  • contentType - the content type. Required for case of Stream data. Ex. image/jpeg.
  • knownLength - the content length in bytes. Required for case of Stream data.

If an attachment object does not satisfy those valid conditions it is ignored. Multiple attachments can be sent by passing an array in the attachment parameter. The array elements can be of any one of the valid types and each one will be handled appropriately.

var mailgun = require('mailgun-js')({apiKey: api_key, domain: domain});
var filename = 'mailgun_logo.png';
var filepath = path.join(__dirname, filename);
var file = fs.readFileSync(filepath);

var attch = new mailgun.Attachment({data: file, filename: filename});

var data = {
  from: 'Excited User <me@samples.mailgun.org>',
  to: 'serobnic@mail.ru',
  subject: 'Hello',
  text: 'Testing some Mailgun awesomeness!',
  attachment: attch
};

mailgun.messages().send(data, function (error, body) {
  console.log(body);
});
var mailgun = require('mailgun-js')({apiKey: api_key, domain: domain});
var filename = 'mailgun_logo.png';
var filepath = path.join(__dirname, filename);
var fileStream = fs.createReadStream(filepath);
var fileStat = fs.statSync(filepath);

msg.attachment = new mailgun.Attachment({
  data: fileStream,
  filename: 'my_custom_name.png',
  knownLength: fileStat.size,
  contentType: 'image/png'});

mailgun.messages().send(data, function (error, body) {
  console.log(body);
});

Sending MIME messages

Sending messages in MIME format can be accomplished using the sendMime() function of the messages() proxy object. The data parameter for the function has to have to and message properties. The message property can be a full file path to the MIME file, a stream of the file, or a string representation of the MIME message. To build a MIME string you can use the nodemailer library. Some examples:

var domain = 'mydomain.org';
var mailgun = require('mailgun-js')({ apiKey: "YOUR API KEY", domain: domain });
var MailComposer = require('nodemailer/lib/mail-composer');

var mailOptions = {
  from: 'you@samples.mailgun.org',
  to: 'mm@samples.mailgun.org',
  subject: 'Test email subject',
  text: 'Test email text',
  html: '<b> Test email text </b>'
};

var mail = new MailComposer(mailOptions);

mail.compile().build((err, message) => {

    var dataToSend = {
        to: 'mm@samples.mailgun.org',
        message: message.toString('ascii')
    };

    mailgun.messages().sendMime(dataToSend, (sendError, body) => {
        if (sendError) {
            console.log(sendError);
            return;
        }
    });
});

Referencing MIME file

var filepath = '/path/to/message.mime';

var data = {
  to: fixture.message.to,
  message: filepath
};

mailgun.messages().sendMime(data, function (err, body) {
  console.log(body);
});
var filepath = '/path/to/message.mime';

var data = {
  to: fixture.message.to,
  message: fs.createReadStream(filepath)
};

mailgun.messages().sendMime(data, function (err, body) {
  console.log(body);
});

Creating mailing list members

members().create({data}) will create a mailing list member with data. Mailgun also offers a resource for creating members in bulk. Doing a POST to /lists/<address>/members.json adds multiple members, up to 1,000 per call, to a Mailing List. This can be accomplished using members().add().

var members = [
  {
    address: 'Alice <alice@example.com>',
    vars: { age: 26 }
  },
  {
    name: 'Bob',
    address: 'bob@example.com',
    vars: { age: 34 }
  }
];

mailgun.lists('mylist@mycompany.com').members().add({ members: members, subscribed: true }, function (err, body) {
  console.log(body);
});

Generic requests

Mailgun-js also provides helper methods to allow users to interact with parts of the api that are not exposed already. These are not tied to the domain passed in the constructor, and thus require the full path with the domain passed in the resource argument.

  • mailgun.get(resource, data, callback) - sends GET request to the specified resource on api.
  • mailgun.post(resource, data, callback) - sends POST request to the specified resource on api.
  • mailgun.delete(resource, data, callback) - sends DELETE request to the specified resource on api.
  • mailgun.put(resource, data, callback) - sends PUT request to the specified resource on api.

Example: Get some stats

mailgun.get('/samples.mailgun.org/stats', { event: ['sent', 'delivered'] }, function (error, body) {
  console.log(body);
});

Promises

Module works with Node-style callbacks, but also implements promises with the promisify-call library.

mailgun.lists('mylist@mydomain.com').info().then(function (data) {
  console.log(data);
}, function (err) {
  console.log(err);
});

The function passed as 2nd argument is optional and not needed if you don't care about the fail case.

Webhook validation

The Mailgun object also has a helper function for validating Mailgun Webhook requests (as per the mailgun docs for securing webhooks). This code came from this gist.

Example usage:

var mailgun = require('mailgun-js')({apiKey: api_key, domain: domain});

function router(app) {
  app.post('/webhooks/mailgun/*', function (req, res, next) {
    var body = req.body;

    if (!mailgun.validateWebhook(body.timestamp, body.token, body.signature)) {
      console.error('Request came, but not from Mailgun');
      res.send({ error: { message: 'Invalid signature. Are you even Mailgun?' } });
      return;
    }

    next();
  });

  app.post('/webhooks/mailgun/catchall', function (req, res) {
    // actually handle request here
  });
}

Email Addresses validation

These routes require Mailgun public API key. Please check Mailgun email validation documentation for more responses details.

Validate Email Address

mailgun.validate(address, private, options, fn)

Checks if email is valid.

  • private - whether it's private validate
  • options - any additional options

Example usage:

var mailgun = require('mailgun-js')({apiKey: api_key, domain: domain});

mailgun.validate('test@mail.com', function (err, body) {
  if(body && body.is_valid){
    // do something
  }
});

Parse Email Addresses list

Parses list of email addresses and returns two lists:

  • parsed email addresses
  • unparseable email addresses

Example usage:

var mailgun = require('mailgun-js')({apiKey: api_key, domain: domain});

mailgun.parse([ 'test@mail.com', 'test2@mail.com' ], function (err, body) {
  if(error){
    // handle error
  }else{
    // do something with parsed addresses: body.parsed;
    // do something with unparseable addresses: body.unparseable;
  }
});

Debug logging

debug package is used for debug logging.

DEBUG=mailgun-js node app.js

Test mode

Test mode can be turned on using testMode option. When on, no requests are actually sent to Mailgun, rather we log the request options and applicable payload and form data. By default we log to console.log, unless DEBUG is turned on, in which case we use debug logging.

mailgun = require('mailgun-js')({ apiKey: api_key, domain: domain, testMode: true })

const data = {
  from: 'mailgunjs+test1@gmail.com',
  to: 'mailgunjstest+recv1@gmail.com',
  subject: 'Test email subject',
  text: 'Test email text'
};

mailgun.messages().send(data, function (error, body) {
  console.log(body);
});
options: { hostname: 'api.mailgun.net',
  port: 443,
  protocol: 'https:',
  path: '/v3/sandbox12345.mailgun.org/messages',
  method: 'POST',
  headers:
   { 'Content-Type': 'application/x-www-form-urlencoded',
     'Content-Length': 127 },
  auth: 'api:key-0e8pwgtt5ylx0m94xwuzqys2-o0x4-77',
  agent: false,
  timeout: undefined }
payload: 'to=mailgunjs%2Btest1%40gmail.com&from=mailgunjstest%2Brecv1%40gmail.com&subject=Test%20email%20subject&text=Test%20email%20text'
form: undefined
undefined

Note that in test mode no error or body are returned as a result.

The logging can be customized using testModeLogger option which is a function to perform custom logging.

const logger = (httpOptions, payload, form) => {
  const { method, path } = httpOptions
  const hasPayload = !!payload
  const hasForm = !!form

  console.log(`%s %s payload: %s form: %s`, method, path, hasPayload, hasForm)
}

mailgun = require('mailgun-js')({ apiKey: api_key, domain: domain, testMode: true, testModeLogger: logger })

const data = {
  from: 'mailgunjs+test1@gmail.com',
  to: 'mailgunjstest+recv1@gmail.com',
  subject: 'Test email subject',
  text: 'Test email text'
};

mailgun.messages().send(data, function (error, body) {
  console.log(body);
});

Sample output:

POST /v3/sandbox12345.mailgun.org/messages payload: true form: false
undefined

Tests

To run the test suite you must first have a Mailgun account with a domain setup. Then create a file named ./test/data/auth.json, which contains your credentials as JSON, for example:

{ "api_key": "XXXXXXXXXXXXXXXXXXXXXXX", "public_api_key": "XXXXXXXXXXXXXXXXXXXXXXX", "domain": "mydomain.mailgun.org" }

You should edit ./test/data/fixture.json and modify the data to match your context.

Then install the dev dependencies and execute the test suite:

$ npm install
$ npm test

The tests will call Mailgun API, and will send a test email, create route(s), mailing list and mailing list member.

Notes

This project is not endorsed by or affiliated with Mailgun. The general design and some code was heavily inspired by node-heroku-client.

License

Copyright (c) 2012 - 2017 OneLobby and Bojan D.

Licensed under the MIT License.