2017-02-24 69 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); 
    } 
}); 

此解決方案適用於我。

相關問題