Socket
Socket
Sign inDemoInstall

parse-mail-adapter-smtp-ejs

Package Overview
Dependencies
15
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    parse-mail-adapter-smtp-ejs

Parse Server Mail Adapter with ejs tempates (SMTP)


Version published
Weekly downloads
5
Maintainers
1
Install size
1.78 MB
Created
Weekly downloads
 

Readme

Source

parse-mail-adapter-smtp-ejs

Parse Server Mail Adapter with EJS templates (SMTP)

Installation

Install npm module in your parse server project

$ npm install --save parse-mail-adapter-smtp-ejs
$ yarn add parse-mail-adapter-smtp-ejs

Use

"use strict";

const Express = require('express');
const ParseServer = require('parse-server').ParseServer;

const app = Express();
const APP_PORT = 8080;


let api = new ParseServer({
    appName: "Parse Test",
    appId: "appid",
    masterKey: "secret",
    serverURL: "http://localhost:8080/parse",
    publicServerURL: "http://localhost:8080/parse",
    databaseURI: "mongodb://user:pass@host:27017/parse",
    port: APP_PORT,
    //This is the config for email adapter
    emailAdapter: {
        module: "parse-mail-adapter-smtp-ejs",
        options: {

            nodeMailerOptions: {
                host: 'your.smtp.host',
                port: 465,
                secure: true, //True or false if you are using ssl 
                auth: {
                    user: 'email@email.com',
                    pass: 'AwesomePassword',
                }
                // you can add here other custom props for nodemailer like "tls"...
            },

            defaultFrom: 'noreply@sender.address', // Use for ResetPassword, VerifyEmail

            templatesOptions: {
                locales: ["en", "fr"],
                defaultLocale: "en",
                templatesDir: __dirname + '/templates/',

                templates: {
                    //This template is used only for reset password email
                    //The locale used for these templates is the one of user.get("locale") or the default locale
                    resetPassword: {
                        //Name to your template
                        template:'reset-password.html',
                        //Subject for this email
                        subject: 'Reset your password'
                    },
                    verifyEmail: {
                        template: 'verify-email.html',
                        subject: 'Verify Email'
                    }
                }
            }
            
        }
    }
});


app.use('/parse', api);

app.listen(APP_PORT, function () {
	console.log(`Parse Server Ready and listening on port ${APP_PORT}`);
});

Template

Architecture
templates/
└── en/                 // en locale folder
│   └── example.html    // en localized file
└── fr/                 // fr locale folder
│   └── example.html    // fr localized file
Variables (resetPassword & verifyMail)
  • appName //This is the name of your parse app
  • link //This is the link for reset the password
  • user //This is a Parse object of the current user

Send Mail From Cloud Code

=> Parse Server >= 5.0.0

Parse.Cloud.sendEmail({
    template: "myTemplate.html", // Email Html
    locale: "en",
    from: "your@sender.address",
    to: "user@email.address",
    subject: "my Subejct",
    text: "", // Email Text
    data: {} // data gives to ejs
});

=> Parse Server < 5.0.0

// Import on top
const { AppCache } = require('parse-server/lib/cache');

// To use in code
const MailAdapter = AppCache.get('appid').userController.adapter;
await MailAdapter.sendMail({
    template: "myTemplate.html", // Email Html
    locale: "en",
    from: "your@sender.address",
    to: "user@email.address",
    subject: "my Subejct",
    text: "", // Email Text
    data: {} // data gives to ejs
});

License MIT

Keywords

FAQs

Last updated on 05 May 2022

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc