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-smtp-unison-template

v1.0.6

Published

Parse Server Module to send emails via SMTP with individual templates

Downloads

26

Readme

About

Original Author and Project: https://github.com/macarthuror/parse-smtp-template

Customize Parse Servers default Emails

In order to use Parse Servers default Emails and customize them, you need to add the Adapter to your server configuration file like so:

var api = new ParseServer({
    appId: 'myParseHosting',
    masterKey: 'master123',
    ...
    emailAdapter: {
        module: 'parse-smtp-unison-template',
        options: {
            port: 587,
            host: "smtp.mail.com",
            user: "[email protected]",
            password: "SecurePassword",
            fromAddress: '[email protected]',
            secure: true,
            templates: [
              { name: "default", path: "/views/templates/template.html", variables: { subject: "Email von Parse", username: "[email protected]", btn: "Klicke hier", link: "https://www.google.com", appName: "default appname" } },
              { name: "verificationEmail", path: "/views/templates/verificationEmail.html", variables: { subject: "Email Adresse bestätigen", btn: "Jetzt bestätigen" } },
              { name: "passwordResetEmail", path: "/views/templates/passwordResetEmail.html", variables: { subject: "Passwort zurücksetzen", btn: "Jetzt zurücksetzen" } }
            ]
        }
    }
})

Then you need to put your .html Email Template file to the correct path. Feel free to use more templates added the same way.

The variables Object can contain any data you want to use in your email template. Once you've added it in the templates-Array, they become available as ${option.variableName} in the .html Email template file.

Send custom Emails through Parse Clode Code

You can also send emails through Parse Cloud Code by adding the adapter and then passing in variables and template names. Example:

// Define a cloud function in Parse Cloud Code named testmail
Parse.Cloud.define('testmail', async (request) => {
  // Load some variables to use in your mailings
  const courseName = 'Learn sending mails from parse';
  const courseCode = 'SM-1337';
  const semester = request.params.semester; // Variable used from the Parse Cloud request
  
  // Define the sendMail Function when we need it and set up server settings and template
  const { sendMail } = require('parse-smtp-unison-template')({
      user: '[email protected]',
      password: "SecurePassword",
      fromAddress: '[email protected]',
      host: "smtp.mail.com",
      port: 465,
      secure: true,
      templates: [
        { name: 'invoice', path: '/views/templates/invoiceEmail.html', 'variables': { courseName, courseCode, semester } }
        // Add more Templates if you like. Careful with path to the template relative to cloud code file
        ]
  });
	
  // Set up more variables, error handling and so on, then send the email
  return sendMail({
      to: '[email protected]',
      subject: 'Invoice for course ' + courseName,
      template: 'invoice',
      // attachments are also an option as array
  }); 
});

Then use Parse.Cloud.run('testmail') to send your mail in your SDK or other Cloud Code.

All data that you pass in through the sendMail Object overrides the ones in the template. If your template is not found, the one named "default" is used.

All data passed into the variables Object when instantiating the sendMail function overrides already set static data of the template. This is relevant when using password reset or email verify emails from parse.

You can use any variables you wish in your template, but make sure they match the ones you send in your function. E.g. the passed variable courseCode becomes available in our .html Email Template as ${option.courseCode}