使用 Google Apps 脚本设置 Sendinblue 邮件服务
Setting up Sendinblue mail service with Google Apps Script
我正在尝试使用 Google Apps 脚本设置 Sendinblue 的邮件服务,如下所示:
code.gs
function sendInBlue(){
eval(UrlFetchApp.fetch('https://cdn.rawgit.com/mailin-api/mailin-api-node-js/master/V2.0/mailin.js').getContentText());
var client = new Mailin("https://api.sendinblue.com/v2.0","your access key");
data = {
"to" : {"to@example.net":"to whom!"},
"from" : ["from@email.com", "from email!"],
"subject" : "My subject",
"html" : "This is the <h1>HTML</h1>"
}
client.send_email(data).on('complete',function(data){console.log(data);});
}
错误信息:参考错误:"require"未定义。
sendinblue node.js 库谈到还需要一个 Restler 库,但我真的不确定如何合并这个库?
我是新手,所以在这里可能完全偏离轨道。
感谢任何指导。
文档:
https://apidocs.sendinblue.com/tutorial-sending-transactional-email/
https://github.com/mailin-api/mailin-api-node-js/tree/master/V2.0
使用 Sendinblue 的邮件服务发送电子邮件的代码可能如下所示:
function sendEmailWithSendInBlue() {
var url = "https://api.sendinblue.com/v3/smtp/email";
var myAccessKey = "[enter your v3 access key]"
var data = {
"sender":{"name":"Name","email":"name@domain.com"},
"htmlContent":"this is the body",
"subject":"subject",
"replyTo":{"email":"name@domain.com","name":"Name"},
"to":[{"email":"name@domain.com","name":"Name"}]
}
var options = {
'method': 'post',
'contentType': 'application/json',
'payload': JSON.stringify(data),
'headers': {'api-key':myAccessKey},
};
var response = UrlFetchApp.fetch(url, options);
Logger.log(response.getResponseCode())
}
我正在尝试使用 Google Apps 脚本设置 Sendinblue 的邮件服务,如下所示:
code.gs
function sendInBlue(){
eval(UrlFetchApp.fetch('https://cdn.rawgit.com/mailin-api/mailin-api-node-js/master/V2.0/mailin.js').getContentText());
var client = new Mailin("https://api.sendinblue.com/v2.0","your access key");
data = {
"to" : {"to@example.net":"to whom!"},
"from" : ["from@email.com", "from email!"],
"subject" : "My subject",
"html" : "This is the <h1>HTML</h1>"
}
client.send_email(data).on('complete',function(data){console.log(data);});
}
错误信息:参考错误:"require"未定义。
sendinblue node.js 库谈到还需要一个 Restler 库,但我真的不确定如何合并这个库? 我是新手,所以在这里可能完全偏离轨道。
感谢任何指导。
文档:
https://apidocs.sendinblue.com/tutorial-sending-transactional-email/
https://github.com/mailin-api/mailin-api-node-js/tree/master/V2.0
使用 Sendinblue 的邮件服务发送电子邮件的代码可能如下所示:
function sendEmailWithSendInBlue() {
var url = "https://api.sendinblue.com/v3/smtp/email";
var myAccessKey = "[enter your v3 access key]"
var data = {
"sender":{"name":"Name","email":"name@domain.com"},
"htmlContent":"this is the body",
"subject":"subject",
"replyTo":{"email":"name@domain.com","name":"Name"},
"to":[{"email":"name@domain.com","name":"Name"}]
}
var options = {
'method': 'post',
'contentType': 'application/json',
'payload': JSON.stringify(data),
'headers': {'api-key':myAccessKey},
};
var response = UrlFetchApp.fetch(url, options);
Logger.log(response.getResponseCode())
}