npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

parse-server-amazon-ses-email-adapter

v1.0.0

Published

Send parse-server template emails with Amazon SES. Based off parse-server-mailgun.

Downloads

100

Readme

Parse Server Amazon SES Email Adapter CircleCI

Used to send Parse Server emails with Amazon SES. (based on parse-server-mailgun)

AmazonSES node module

amazon-ses-mailer

Install

$ npm install parse-server-amazon-ses-email-adapter --save

Usage

Replace the config with your info. You can find your AWS SES credentials here: http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSGettingStartedGuide/AWSCredentials.html

In addition, you also need to configure the templates you want to use. You must provide at least a plain-text version for each template. The html versions are optional.

//...otherOptions,
emailAdapter: {
  module: 'parse-server-amazon-ses-email-adapter',
  options: {
    // The address that your emails come from
    fromAddress: 'Your Name <[email protected]>',
    accessKeyId: 'Your AWS IAM Access Key ID',
    secretAccessKey: 'Your AWS IAM Secret Access Key',
    region: 'Your AWS Region',
    // The template section
    templates: {
      passwordResetEmail: {
        subject: 'Reset your password',
        pathPlainText: resolve(__dirname, 'path/to/templates/password_reset_email.txt'),
        pathHtml: resolve(__dirname, 'path/to/templates/password_reset_email.html'),
        callback: (user) => {
            return {
              firstName: user.get('firstName')
            }
          }
          // Now you can use {{firstName}} in your templates
      },
      verificationEmail: {
        subject: 'Confirm your account',
        pathPlainText: resolve(__dirname, 'path/to/templates/verification_email.txt'),
        pathHtml: resolve(__dirname, 'path/to/templates/verification_email.html'),
        callback: (user) => {
            return {
              firstName: user.get('firstName')
            }
          }
          // Now you can use {{firstName}} in your templates
      },
      customEmailAlert: {
        subject: 'Urgent notification!',
        pathPlainText: resolve(__dirname, 'path/to/templates/custom_alert.txt'),
        pathHtml: resolve(__dirname, 'path/to/templates/custom_alert.html'),
      }
    }
  }
}

Templates

The Parse Server uses the AmazonSESAdapter for only two use cases: password reset and email address verification. With a few lines of code, it's also possible to use the AmazonSESAdapter directly, so that you can send any other template-based email, provided it has been configured as shown in the example configuration above.

// Get access to Parse Server's cache
// With ES2015 syntax:
const { AppCache } = require('parse-server/lib/cache');
// Or with old-school JS:
const AppCache = require('parse-server/lib/cache').AppCache;
// Get a reference to the AmazonSESAdapter
const AmazonSESAdapter = AppCache.get('yourAppId')['userController']['adapter'];
// Invoke the send method with an options object
AmazonSESAdapter.send({
  templateName: 'customEmailAlert',
  // Optional override of your configuration's subject
  subject: 'Important: action required',
  // Optional override of the adapter's fromAddress
  fromAddress: 'Alerts <[email protected]>',
  recipient: '[email protected]',
  variables: { alert: 'New posts' } // {{alert}} will be compiled to 'New posts'
});

Sample templates and template variables

In the test directory, there are a few examples to get you started.

For password reset and address verification messages, you can use the following template variables by default:

  • {{link}} - the reset or verification link provided by the Parse Server
  • {{appName}} - as is defined in your Parse Server configuration object
  • {{username}} - the Parse.User object's username property
  • {{email}} - the Parse.User object's email property

Additional variables can be introduced by adding a callback. An example is shown in the configuration above. The relevant Parse.User object is passed as an argument. The return value must be a plain object where the property names exactly match their template counterparts. Note: the callback options only applies to the password reset and email address verification use cases.

For any other use case, you use the AmazonSESAdapter directly and pass any variable you need to the send method as explained in the code sample above.