How to use the postmark.Client function in postmark

To help you get started, we’ve selected a few postmark examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wildbit / postmark_webhooks / server / main.js View on Github external
import settings from './settings.js'
import bounces from './bounces.js';
import opens from './opens.js';
import inbound_messages from './inbound_messages.js'

Router.onBeforeAction(Iron.Router.bodyParser.json({limit: '50mb'}));

// Uses Postmark Node.js to send emails.
// Replace  with your Server API Token.
// You can retrieve this by logging into Postmark,
// accessing your server, and clicking Credentials. See
// https://www.npmjs.com/package/postmark for more information

let postmark = require("postmark");
if (process.env.POSTMARK_API_TOKEN) {
  let client = new postmark.Client(process.env.POSTMARK_API_TOKEN);
} else {
  let client = new postmark.Client('POSTMARK_API_TEST');
}


// Receive POST w/ Bounce Information to /webhook/bounces.
// See https://postmarkapp.com/developer/webhooks/bounce-webhook
// for more Information

Router.route('/webhooks/bounces', function() {

  let stored_json = this.request.body;
  let headers = this.request.headers;
  let clientIP = headers["x-forwarded-for"];
  stored_json.created_at = new Date();
  console.log("Bounce Received (Postmark Bounce ID): " + stored_json.ID);
github forwardemail / email-templates / examples / postmark / index.js View on Github external
// [1]: http://postmarkapp.com/
// [2]: https://github.com/voodootikigod/postmark.js

// **NOTE**: Did you know `nodemailer` can also be used to send SMTP email through Postmark?
// 

// For more message format options, see Postmark's developer documentation section:
// 

var path = require('path')
var EmailTemplate = require('../../').EmailTemplate
var postmark = require('postmark')
var _ = require('lodash')

var templatesDir = path.resolve(__dirname, '..', 'templates')
var client = new postmark.Client('your-server-key')

var locals = {
  email: 'mamma.mia@spaghetti.com',
  name: {
    first: 'Mamma',
    last: 'Mia'
  }
}

var template = new EmailTemplate(path.join(templatesDir, 'newsletter'))

// Send a single email
template.render(locals, function (err, results) {
  if (err) {
    return console.error(err)
  }
github wildbit / postmark_webhooks / server / main.js View on Github external
import opens from './opens.js';
import inbound_messages from './inbound_messages.js'

Router.onBeforeAction(Iron.Router.bodyParser.json({limit: '50mb'}));

// Uses Postmark Node.js to send emails.
// Replace  with your Server API Token.
// You can retrieve this by logging into Postmark,
// accessing your server, and clicking Credentials. See
// https://www.npmjs.com/package/postmark for more information

let postmark = require("postmark");
if (process.env.POSTMARK_API_TOKEN) {
  let client = new postmark.Client(process.env.POSTMARK_API_TOKEN);
} else {
  let client = new postmark.Client('POSTMARK_API_TEST');
}


// Receive POST w/ Bounce Information to /webhook/bounces.
// See https://postmarkapp.com/developer/webhooks/bounce-webhook
// for more Information

Router.route('/webhooks/bounces', function() {

  let stored_json = this.request.body;
  let headers = this.request.headers;
  let clientIP = headers["x-forwarded-for"];
  stored_json.created_at = new Date();
  console.log("Bounce Received (Postmark Bounce ID): " + stored_json.ID);
  console.log("Headers: " + JSON.stringify(headers));
github simdo / rest.api / models / user / methods / index.js View on Github external
case 'password':
      options.TemplateId = env.postmark.password
      break

    // send email about successfully authorisation with IP address, user-agent, 
    // datetime and other important information if user email notifications is enabled
    case 'security':
      options.TemplateId = env.postmark.security
      break

    // by default
    default:
      return callback('Invalid sendmail type')
  }
  // postmark client send with templates see https://github.com/wildbit/postmark.js
  const client = new postmark.Client(env.postmark.secret)
  client.sendEmailWithTemplate(options, callback)
}
github AraiEzzra / DDKCORE / backlog / helpers / postmark.js View on Github external
const postmark = require('postmark');

// Send an email:
// TODO change to bootstrapPostmark in which will be use in app.js
const client = new postmark.Client(process.env.POSTMARK_KEY);

postmark.sendEmailWithTemplate = function (mailOptions, callback) {
    client.sendEmailWithTemplate(mailOptions, (err) => {
        if (err) {
            return callback(err);
        }
        return callback(null);
    });
};

postmark.sendMail = function (mailOptions, callback) {
    client.sendEmail(mailOptions, (err) => {
        if (err) {
            return callback(err);
        }
        return callback(null);
github wp-pwa / worona-dashboard / server / accounts / methods.js View on Github external
const token = Random.secret();
    const when = new Date();
    const tokenRecord = {
      token,
      email,
      when,
    };
    Meteor.users.update(userId, {
      $set: {
        'services.password.reset': tokenRecord,
      },
    });
    // before passing to template, update user object with new token
    Meteor._ensure(user, 'services', 'password').reset = tokenRecord;

    const client = new PostmarkClient(Meteor.settings.postmark.serverKey);
    const sendEmailWithTemplate = Meteor.wrapAsync(client.sendEmailWithTemplate, client);

    const res = sendEmailWithTemplate({
      From: 'support@worona.org',
      TemplateId: 1287034,
      To: email,
      TemplateModel: {
        name: user.profile.name,
        action_url: `https://dashboard.worona.org/recover-password?token=${tokenRecord.token}`,
      },
    });

    return res;
  },
});
github DefinitelyTyped / DefinitelyTyped / types / postmark / postmark-tests.ts View on Github external
declare const options: typeof postmark.defaults;
const message = { To: "me", From: "you" };
const templateMessage = { ...message, TemplateId: "1" };
const filter = { offset: 0 };
const editSender = { Color: "black" };
const templateValidator = {
    Subject: "123",
    HtmlBody: "123345",
    TextBody: "123535"
};

declare const error: postmark.PostmarkError;

declare function callback(err: any, data: any): undefined;

const client = new postmark.Client("124345", options);
const adminClient = new postmark.AdminClient("1123235", options);

client.send(message, callback);
client.sendEmailWithTemplate(templateMessage, callback);
client.batch([message, message], callback);
client.sendEmail(message, callback);
client.sendEmailBatch([message, message], callback);
client.getDeliveryStatistics(callback);
client.getBounces(filter, callback);
client.getBounce(1, callback);
client.getBounceDump(1, callback);
client.activateBounce(1, callback);
client.getBounceTags(callback);
client.getServer(callback);
client.editServer(editSender, callback);
client.getOutboundMessages(filter, callback);
github staticland / staticland-api / lib / email.js View on Github external
module.exports = function createMailer (config, cb) {
  assert.equal(typeof config, 'object', 'config object is required')
  assert.equal(typeof config.fromEmail, 'string', 'config.fromEmail is required')
  assert.equal(typeof config.postmarkAPIKey, 'string', 'config.fromEmail property is required')

  var client = new postmark.Client(config.postmarkAPIKey)

  function send (msg, callback) {
    assert.equal(typeof msg, 'object', 'msg object is required')
    assert.equal(typeof msg.to, 'string', 'msg.to property is required and must be a string')
    assert.equal(typeof msg.subject, 'string', 'msg.subject property is required and must be a string')
    assert.ok(msg.text || msg.html, 'either msg.text or msg.html properties are required')
    assert.equal(typeof callback, 'function', 'callback function is required')

    client.sendEmail({
      'From': msg.from || config.fromEmail,
      'To': msg.to,
      'Subject': msg.subject,
      'TextBody': msg.text,
      'HtmlBody': msg.html,
      'Tag': msg.tag
    }, callback)
github prisma-archive / graphcool-templates / outdated / auth / email-user-management / functions / reset-password / server / postmark-email / sendPasswordResetEmail.js View on Github external
var postmark = require('postmark')
var client = new postmark.Client('___TOKEN____')

module.exports = function (event) {
  const email = event.data.User.node.email
  const resetToken = event.data.User.node.resetToken
  const firstName = event.data.User.node.firstName

  if (!resetToken) {
    return
  }

  client.sendEmailWithTemplate({
    'From': 'mike@example.com',
    'TemplateId': 2508781,
    'To': email,
    'TemplateModel': {
      'firstName': firstName,
github impraise / react-mailmerge / shared / email.js View on Github external
constructor(token) {
    this.client = new PostmarkClient(token);
  }

postmark

Official Node.js client library for the Postmark HTTP API - https://www.postmarkapp.com

MIT
Latest version published 6 months ago

Package Health Score

76 / 100
Full package analysis