Sending emails in Node.js using the postmark.js module

The following example shows how you can send emails in Node.js using Postmark and the postmark.js Node.js module.

First, sign up for the Postmark service (they have a free tier which allows you to send 1000 emails per month, plus $1.50 for each additional 1000 emails). Once your account is created, copy your API key for use w/ Node.js.

Next, install the postmark.js module using npm:

npm install postmark

Create a JavaScript file, app.js, in the same directory as you installed the postmark module and paste the following contents:

#!/usr/bin/env node

// Paste your API key here...
var POSTMARK_KEY = "00000000-0xxx-0xx0-x000-xx00x00xx00x";

var postmark = require("postmark")(POSTMARK_KEY);

    "From": "", 
    "To": "", 
    "Subject": "This is a subject", 
    "TextBody": "This is a message body"
}, function (err, to) {
    if (err) {
    console.log("Email sent to: %s", to);

Set your Postmark API key in the top of the previous code and change the From email to the email address you registered with Postmark, and set the To email addresses to a valid email address and run your Node.js application by typing the following command in your Terminal:

node ./app.js

Note: If you don’t change the From address to the email address registered with Postmark, the callback function will get an object similar to the following:

    status: 422,
    message: 'Sender signature not defined for From address.'

1 comment

  1. Really Good One Peter! Thanks.

    I tried same process but consistently I am getting
    status: 422,
    message: ‘Sender signature not defined for From address.’

    I registered with and Got the Api keys.

    I am not sure what I am doing wrong here,Could you please help me.

    Thanks in advance.

Leave a Reply

Your email address will not be published.