0
我試圖使用節點郵件發送郵件。獲取的HTML標記,從通過外部file.External文件的HTML模板玉,就是利用文件流和正常顯示,而無論通過maxcdn插入或cdnjs的風格並不反映如何使用jade&express將cdnjs css或external css應用於nodemailer html模板
在這種情況下如何應用CSS或者是有編制任何其他替代方法來實現這種情況。
玉模板
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 you for registering with us you applucation submitted succesfully
.row
.col-md-4
p Thanks,
p SnapCode Team
節點服務器代碼
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
@ krishna-m如果它是一個自定義的CSS我們可以這樣做考慮引導或基礎的CSS將您複製和粘貼整個CSS樣式標籤? – rselvaganesh
@rselvaganesh這會給電子郵件增加太多的權重。我寧願最小限度地使用它們。但是,我非常肯定你不能鏈接到外部CSS。 –