Skip to content

Instantly share code, notes, and snippets.

@bilashcse
Created November 7, 2016 11:20
Show Gist options
  • Save bilashcse/34674ffa74f55d37b835b1b231f3bd9c to your computer and use it in GitHub Desktop.
Save bilashcse/34674ffa74f55d37b835b1b231f3bd9c to your computer and use it in GitHub Desktop.
Email send with html template using ejs template engine on NodeJs
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
});
@varunrayen
Copy link

How do you render the value in the ejs page?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment