2017-02-24 68 views

回答

1

您可以在使用可变fs和商店做this.Read HTML文件,现在把这个变量电子邮件数据

试试下面的代码。

var fs = require('fs'); 
var mailGun = require("mailgun-js")({ 
    apiKey: "API-KEY", 
    domain:"DOMAIN-NAME" 
}); 
var emailBody = fs.readFileSync('your html file path').toString(); 
var emailData = { 
    from: "fromEmail", 
    to: "toEmail", 
    subject: "subject", 
    html: emailBody 
} 
mailGun.messages().send(emailData, function (error, body) { 
    if(!error){ 
     console.log("sendEmail : email Sent to : "+email); 
    }else{ 
     console.log("sendEmail : Can not send email to : "+email+" : Error : "+error); 
    } 
}); 

此解决方案适用于我。

相关问题