Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
parse-smtp-unison-template
Advanced tools
Parse Server Module to send emails via SMTP with individual templates
Readme
Original Author and Project: https://github.com/macarthuror/parse-smtp-template
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: "name@domain.com",
password: "SecurePassword",
fromAddress: 'app@domain.com',
secure: true,
templates: [
{ name: "default", path: "/views/templates/template.html", variables: { subject: "Email von Parse", username: "test@mail.de", 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.
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: 'mail@mail.com',
password: "SecurePassword",
fromAddress: 'app@domain.com',
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: 'recipient@othermail.com',
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}
FAQs
Parse Server Module to send emails via SMTP with individual templates
The npm package parse-smtp-unison-template receives a total of 1 weekly downloads. As such, parse-smtp-unison-template popularity was classified as not popular.
We found that parse-smtp-unison-template demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.