handlebars.js - How to use handlebars with nodemailer to send email? -


i using nodemailer send emails using following nodemailer-express-handlebars plugin. used blog post reference

the code compiling welcome template not using layout

my code below:

var nodemailer = require('nodemailer'); var mg = require('nodemailer-mailgun-transport'); var hbs = require('nodemailer-express-handlebars');  var config = {auth: {api_key: "key-xxx",domain: "mydomain.com}} var nodemailertransport = nodemailer.createtransport(mg(config));  var options = {     viewengine: {         extname: '.handlebars',         layoutsdir: 'views/email/',         defaultlayout : 'layout',     },     viewpath: 'views/email/' }  nodemailertransport.use('compile', hbs(options));  nodemailertransport.sendmail({         from: 'from@mydomain.com',         to: 'to@gmail.com',         subject: 'welcome xxx',         template: 'welcome'     }, function (err, results) {         if (err) console.log('error: ' + err);         else console.log('response: ' + results); }); 

my layout.handlebars has following code

<html> <body> {{> _header }}     {{{body}}} {{> _footer }} </body> </html> 


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -