我有一些代码用phantomjs发送电子邮件
但是,我总是失败。
我的代码出了什么问题?
function ObjToQs(obj) {
str = '';
for(key in obj) {
str += key + '=' + obj[key] + '&';
}
str = str.slice(0, str.length - 1);
return str;
}
var page = require("webpage").create();
var URL = "https://api.mailgun.net/v3/xxxxxxx.mailgun.org";
var from = "xxx@xxx.com";
var to = "jxxx@xxxx.com";
var data = {
"from" : from,
"to" : to,
"subject" : "Hello!",
"text": "Test from mailgun / phantomjs"
};
page.customHeaders = {
"Authorization": "Basic " + btoa("api:xxxx")
}
page.open(URL, "POST", data, function(status){
if (status === "success") {
console.log("Send Email Success!");
var result = page.evaluate(function () {
return document.body.innerText;
});
console.log("Log Result: " + result);
phantom.exit();
} else {
console.log('FAIL to load the log');
console.log(status);
}
})
我想发送一些错误日志,当我运行phantomjs
时
我曾多次尝试过
但它仍然没有工作
也许有人可以帮助我