This is a full REST API wrapper for Postmark
To use the module, run npm install postmarkapi
First you must make a instance of the module, with your Postmark Server token.
varPostmarkAPI=require('postmarkapi');varpmk=newPostmarkAPI('[your server token]');You always need to define a to for an email, and subject. You can send text or html, or both, but you need to define one or ther other.
If you don't define a from, it will use the address you created the Sender Signature with.
You can send multiple ccs or bccs by passing an array.
You don't need to pass a callback.
// simple examplepmk.email({to: '[email protected]',subject: 'Test Email',text: 'Hello World'});// more specificpmk.email({to: '[email protected]',from: '[email protected]',fromName: 'John Doe',cc: ['[email protected]','[email protected]'],bcc: '[email protected]',reply: '[email protected]',tag: 'MyTag',headers: {EmailedUsing: 'Node PostmarkAPI Module'},subject: 'Test Email',text: 'Hello World',html: '<strong>Hello World</strong>'},function(err,response){// ...});You can also send an email with attachments
varpath=require('path');pmk.email({to: '[email protected]',from: '[email protected]',subject: 'Test Email',text: 'Hello World',html: '<strong>Hello World</strong>',attachments: [path.resolve(__dirname,'cats.gif'),path.resolve(__dirname,'notes.txt')]},function(err,response){// ...});// orpmk.email({to: '[email protected]',from: '[email protected]',subject: 'Test Email',text: 'Hello World',html: '<strong>Hello World</strong>',attachments: [{name: 'orders.csv',content: ordersContent.toString('base64'),contentType: 'text/csv'}]},function(err,response){// ...});pmk.deliverystats(function(err,response){});You can retrieve bounces associated with your server.
// simple examplepmk.bounces({count: 10,offset: 0},function(err,response){});// with messageIdpmk.bounces({messageId: '[messageIDHere]'},function(err,response){});// more sepcificpmk.bounces({count: 10,offset: 0,type: 'HardBounce',inactive: 0,emailFilter: 'somewhere.com'},function(err,response){});pmk.bounceTags(function(err,response){});pmk.bounce(bouncId,function(err,response){});pmk.bounceDump(bouncId,function(err,response){});Callback optional
pmk.bounceActivate(bounceId,function(err,response){});// simple examplepmk.outbound({count: 10,offset: 0},function(err,response){});// more specificpmk.outbound({count: 10,offset: 0,recipient: '[email protected]',fromemail: '[email protected]',tag: 'MyTag',subject: 'Welcome Email'},function(err,response){});pmk.outboundMessage(messageId,function(err,response){});pmk.outboundMessageDump(messageId,function(err,response){});// simple examplepmk.inbound({count: 10,offset: 0},function(err,response){});// more specificpmk.inbound({count: 10,offset: 0,recipient: '[email protected]',fromemail: '[email protected]',tag: 'MyTag',subject: 'Welcome Email',mailboxhash: 'mailboxhashvalue'},function(err,response){});pmk.inboundMessage(messageId,function(err,response){});pmk.senders({count: 10,offset: 0},function(err,response){});pmk.sender(senderId,function(err,response){});The reply and callback are optional
pmk.createSender({name: 'Sender Name',from: '[email protected]',reply: '[email protected]'},function(err,response){});The reply and callback are optional
You cannot update the from address
pmk.updateSender(senderId,{name: 'Sender Name',reply: '[email protected]'},function(err,response){});The callback is optional
pmk.resendSender(senderId,function(err,response){});The callback is optional
pmk.deleteSender(senderId,function(err,response){});The callback is optional
pmk.verifySPF(senderId,function(err,response){});The callback is optional
pmk.requestDKIM(senderId,function(err,response){});pmk.servers({count: 10,offset: 0,name: 'Production'},function(err,response){});pmk.server(serverId,function(err,response){});// simple examplepmk.createServer({name: 'Server Name'});// more specificpmk.createServer({name: 'Server Name',color: 'red',smtp: true,raw: true,inboundHook: 'https://...',bounceHook: 'https://...',inboundDomain: 'myDomain'},function(err,response){});// simple examplepmk.updateServer(serverId,{name: 'Server Name'});// more specificpmk.updateServer(serverId,{name: 'Server Name',color: 'red',smtp: true,raw: true,inboundHook: 'https://...',bounceHook: 'https://...',inboundDomain: 'myDomain'},function(err,response){});The callback is optional
pmk.deleteServer(serverId,function(err,response){});