Coder Social home page Coder Social logo

simple-parse-smtp-adapter's Introduction

Simple Parse Server SMTP Email Adapter

With this adapter you can send email for reset password and email verification in parse with SMTP access and custom templates, I am doing methods for support email verification, and templates for reset password pages :)

Installation

Install npm module in your parse server project

$ npm install --save simple-parse-smtp-adapter

Use

In the configuration of your parse server you must pass simple-parse-smtp-adapter as email adapter and set your SMTP access for send emails also the path to your jade template and its less file.

This is an example using parse server as express module:

"use strict";

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

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

let options = {

};

let api = new ParseServer({
	appName: "Parse Test",
	appId: "12345",
	masterKey: "abcde12345",
	serverURL: "http://localhost:1337/parse",
	publicServerURL: "http://localhost:1337/parse",
	databaseURI: "mongodb://user:pass@host:27017/parse",
	port: APP_PORT,
	//This is the config for email adapter
	emailAdapter: {
		module: "simple-parse-smtp-adapter",
		options: {
			service:'Gmail', // required
			clientId:'your_clientid_get_from_console_google_developers',
            clientSecret:'your_clientsecret_get_from_console_google_developers',
            refreshToken:'your_refresh_token_get_from_console_google_developers',
            accessToken:'your_access_token_get_from_console_google_developers',
			fromAddress: '[email protected]',
			user: '[email protected]', //#"required for service SMTP"
			//password: 'AwesomePassword',  //#"required for service SMTP"
			//host: 'your.smtp.host',  //#"required for service SMTP"
			//isSSL: true, //True or false if you are using ssl  //#"required for service SMTP"
			//port: 465, //SSL port or another port //#"required for service SMTP"
			name: 'your domain name', //  optional, used for identifying to the server 
			//Somtimes the user email is not in the 'email' field, the email is search first in
			//email field, then in username field, if you have the user email in another field
			//You can specify here
			emailField: 'username', 
			templates: {
			    //This template is used only for reset password email
				resetPassword: {
				    //Path to your template
					template: __dirname + '/views/email/reset-password',
					//Subject for this email
					subject: 'Reset your password'
				},
				verifyEmail: {
				    template: __dirname + '/views/email/verify-email',
				    subject: 'Verify Email'
				}
			}
		}
	}
});

/**
 * Parse Server endpoint
 */
app.use('/parse', api);

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

Template

The path you pass to the email adapter must be a directory and not a file, this path must contain 2 mandatory files html.jade and style.less you can do your template as you like with the CSS rules that emails supports in the template you can use 3 variables:

  • appName //This is the name of your parse app
  • link //This is the link for reset the password
  • user //This is a Parse object with the current user, so you can use any field in your User class of parse for example the user name #{user.get('username')}

Contributing

This module is pull request friendly in the develop branch feel free of send new features or bug fixes.

If you find a bug please open an issue.

License MIT

simple-parse-smtp-adapter's People

Contributors

ahmedengu avatar el-mail avatar g3r4n avatar lcortess avatar moumouls avatar prakash-subramani avatar tru3d3v avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.