Created
November 7, 2016 11:20
-
-
Save bilashcse/34674ffa74f55d37b835b1b231f3bd9c to your computer and use it in GitHub Desktop.
Email send with html template using ejs template engine on NodeJs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ejs = require('ejs'); | |
var fs = require('fs'); | |
var nodemailer = require('nodemailer'); | |
var transporter = nodemailer.createTransport({ | |
service: 'gmail', | |
auth: { | |
user: email, | |
pass: password | |
} | |
}); | |
var template = fs.readFileSync('htmlTemplate.html',{encoding:'utf-8'}); | |
var message = ejs.render(template,{ | |
value: value | |
}); | |
transporter.sendMail({ | |
from: from_email, | |
to: to_email, | |
subject: mail_subject, | |
html: message | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How do you render the value in the ejs page?