【发布时间】:2019-11-25 15:19:12
【问题描述】:
您好,我正在为我的项目使用开源 testcafe(不是工作室),一旦我的 testcafe 测试运行,它就会创建一个 testrail-html 报告。现在我想发送通过电子邮件收到的报告。我怎么做。我已经使用 nodemailer 并在一定程度上实现了这一点,邮件发送时附有报告,但是附加到邮件的 html 报告显示为空白,请您帮忙。
var mailer = require("nodemailer");
var smtpTransport = require('nodemailer-smtp-transport');
var transporter = mailer.createTransport(smtpTransport({
host: 'mailo2.abc.com',
}));
// send mail with defined transport object
var mail = {
from: '<john.doe@abc.com>', // sender address
to: "<john.doe@abc.com>'// list of receivers
subject: "Report for ABC Vital Business Function", // Subject line
html: "<b> ABC Vital Business Function Report Attached</b>", // html body
attachments: [{
filename: 'Report.html,
filepath:'.. /test-reports',
}]
}
transporter.sendMail(mail, function(error, response){
if(error){
console.log(error);
}else{
console.log("Message sent: " + response.message);
}
transporter.close();
});
【问题讨论】:
标签: node.js testing report nodemailer testcafe