Skip to content

Getting Started

Igor Balos edited this page Oct 29, 2018 · 25 revisions

Getting started with Postmark is very easy. In order to start using full potential of Postmark API, you will need to:

Account API token is needed only for admins, for managing account details like domains, signatures, etc. To read more about tokens, check out our developer docs.

Sending your first email

Sending email with Postmark is super easy, check out the following code example.

The example shows code in Javascript ES5:

var postmark = require("postmark");
var client = new postmark.ServerClient("<server token>");

client.sendEmail(
    {
        From: "[email protected]",
        To: "[email protected]",
        Subject: "Hello from Postmark!",
        HtmlBody: "Hello message body."
    }
, function(err, data) {
        console.log(err)
        console.log(data) });

Same example using Javascript ES6 code:

let postmark = require("postmark");
let client = new postmark.ServerClient("<server token>");

client.sendEmail(
    {
        From: "[email protected]",
        To: "[email protected]",
        Subject: "Hello from Postmark!",
        HtmlBody: "Hello message body."
    }
).then(response => {
    console.log("Sending message");
    console.log(response.To);
    console.log(response.Message);
});

Please note that in the code example above you need to change to a server token from your account, and you need to change to a verified signature (from address), you created in your account.

To use the full potential of the library, we recommend using Typescript. Detailed documentation of each library method with additional details about types if using typescript can be found here.