javascript - How to apply cdnjs css or external css to nodemailer html template using jade & express -
i'm trying send mail using node mailer. getting html mark jade template through external file.external file html compiled using file stream , rendering whereas style whichever inserted through maxcdn or cdnjs not reflecting
in case how apply css or there other alternate way achieve scenario.
jade template
doctype html html head title application confirmation link(rel='stylesheet', type='text/css', href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css') body .container .row .col-md-4 p thank registering applucation submitted succesfully .row .col-md-4 p thanks, p snapcode team
node server code
var nodemailer = require('nodemailer'); var config_urls = require("../configfile"); var fs = require('fs'); var jade = require('jade'); function readfile() { var template = process.cwd() + '/public/mailtemplate/confirmation.jade'; console.log('template', template); fs.readfile(template, 'utf-8', function(err, file) { if (err) { console.log('template file not found!', template); } else { var compiledtmpl = jade.compile(file, { filename: template }); htmltosend = compiledtmpl(context); return htmltosend; } }); } module.exports = { sendmail: function(email, app_id, callback) { var template = process.cwd() + '/public/mailtemplate/confirmation.jade'; fs.readfile(template, 'utf-8', function(err, file) { if (err) { console.log('template file not found!', template); } else { var compiledtmpl = jade.compile(file, { filename: template }); htmltosend = compiledtmpl(context); var transporter = nodemailer.createtransport({ host: config_urls.url.host, port: config_urls.url.port, secure: true, auth: { user: config_urls.url.gmailid, pass: config_urls.url.gmailpassword } }); var mailoptions = { from: config_urls.url.gmailid, to: email, subject: 'application confirmation', html: htmltosend }; transporter.sendmail(mailoptions, function(error, info) { if (error) { console.log(error); return callback(result = "false"); } console.log('message sent: ' + info.response); return callback(result = "true"); }); } }); }, }; //end of function
as far know, php mailing functions or node mailing functions(i have tried on both , worked both), cannot add external css. write inline styles wherever it's necessary or write styles like
<style> //styles here </style>
i hope helps. please keep me updated. thank you.
Comments
Post a Comment