在nodejs中没有定义styliner?

时间:2018-06-10 13:11:26

标签: html css node.js nodemailer

Hai Everyone我是nodejs的初学者我正在尝试使用nodejs使用 nodemailer smtp transport 模块发送邮件。我想与html模板一起发送邮件。我在html文件夹中分别有 source.html 文件。 source.html文件还包含css 。我在html文件中写了css代码。我正在使用styliner 阅读这些html,css代码。但它在nodejs中显示错误,如未定义样式。任何人都可以解决此问题。提前谢谢......

    function sendEmail(source, fromEmail, toEmail, mats) {

    var nodemailer = require('nodemailer');
    var smtpTransport = require('nodemailer-smtp-transport');


    var transport = nodemailer.createTransport(smtpTransport({
        service:'Gmail',
        host:'smtp.gmail.com',
        port:465,
        auth:{
            user:'demodevelopers6@gmail.com',
            pass:'************'
        },
        tls:{rejectUnauthorized:false}
    }));



    var mailOptions = {
        from: fromEmail,
        to: toEmail,
        subject: mats,
        html: source
    };

    // send mail with defined transport object
    transport.sendMail(mailOptions, function (error, info) {
        if (error) {
            console.log(error);
        } else {
            console.log('Message sent: ' + info.response);
        }
    });


}


var styliner = new Styliner(__dirname + '/html');

var originalSource = require('fs').readFileSync(__dirname + '/html/source.html', 'utf8');

styliner.processHTML(originalSource)
    .then(function(processedSource) {

        sendEmail(processedSource, "developers6@gmail.com", "vignesh.mack03@gmail.com", "Password Reset Link");
    });

enter image description here

0 个答案:

没有答案