Mailgun in Javascript

Posted by Joe Enos on August 17, 2021 · 1 min read

Mailgun is a great email service with reasonable pricing, including a fantastic free tier.

Once you set up the account, sending email from NodeJS is incredibly easy.

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

var data = {
from: 'Some User <>',
to: ',',
subject: 'Hello',
text: 'This is a test!',
html: 'This is a <b>test</b>!'

mailgun.messages().send(data, function (error, body) {