How to use postmark - 10 common examples

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-cli / src / commands / templates / preview.ts View on Github external
const preview = (serverToken: string, args: TemplatePreviewArguments) => {
  const { port, templatesdirectory } = args
  log(`${title} Starting template preview server...`)

  // Start server
  const app = express()
  const server = require('http').createServer(app)
  const io = require('socket.io')(server)

  // Cache manifest and Postmark server
  const client = new ServerClient(serverToken)
  let manifest = createManifest(templatesdirectory)

  // Static assets
  app.use(express.static(`${previewPath}assets`))

  const updateEvent = () => {
    // Generate new manifest
    manifest = createManifest(templatesdirectory)

    // Trigger reload on client
    log(`${title} File changed. Reloading browser...`)
    io.emit('change')
  }

  // Watch for file changes
  createMonitor(untildify(templatesdirectory), { interval: 2 }, monitor => {
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 joshwcomeau / tinkersynth / src / server / email.js View on Github external
import React from 'react';
import ReactDOMServer from 'react-dom/server';

import PurchaseIncludingDownload from './email-templates/purchase-incl-download';
import PurchaseJustPhysicalPrint from './email-templates/purchase-just-physical';
import ShippingNotification from './email-templates/shipping-notification';

const postmark = require('postmark');

const SEND_IN_DEV = false;

// Send an email:
var client = new postmark.ServerClient('b79d4a35-93f3-49b3-ab72-8278293863f6');

export const sendArtVectorEmail = (
  name,
  email,
  format,
  orderId,
  svgUrl,
  pngUrlTransparent,
  pngUrlOpaque
) => {
  // Don't send email in development
  if (!SEND_IN_DEV && process.env.NODE_ENV !== 'production') {
    return;
  }

  const Component =
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 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 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);
    });
};

module.exports = postmark;

postmark

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

MIT
Latest version published 5 months ago

Package Health Score

79 / 100
Full package analysis