Node.js 带有nodejs的附件SendinBlue Api
我想在我的lb4应用程序中使用Sendinblue api来发送邮件 但是我在依恋上有一些困难,我能得到一个清晰的例子吗Node.js 带有nodejs的附件SendinBlue Api,node.js,api,loopback4,sendinblue,Node.js,Api,Loopback4,Sendinblue,我想在我的lb4应用程序中使用Sendinblue api来发送邮件 但是我在依恋上有一些困难,我能得到一个清晰的例子吗 感谢您将sendinblue api V3与loopback4(nodejs)链接起来我遵循了他们中提到的步骤,并使下面的脚本正常工作 var request = require("request"); var options = { method: 'POST', url: 'https://api.sendinblue.com/v3/smtp
感谢您将sendinblue api V3与loopback4(nodejs)链接起来我遵循了他们中提到的步骤,并使下面的脚本正常工作
var request = require("request");
var options = {
method: 'POST',
url: 'https://api.sendinblue.com/v3/smtp/email',
headers: {
accept: 'application/json',
'content-type': 'application/json',
'api-key': 'API-KEY'
},
body: {
sender: {name: 'Your Name', email: 'youremail@gmail.com'},
to: [{email: 'recipient@gmail.com', name: 'Recipient name'}],
attachment: [
{
url: 'http://personal.psu.edu/xqz5228/jpg.jpg', // Should be publicly available and shouldn't be a local file
name: 'myAttachment.jpg'
}
],
htmlContent: 'This is a test Content',
subject: 'This is test Subject'
},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
虽然您没有明确说明附件面临的问题,但我认为这可能与附件url不是绝对url,而是本地文件有关。如果这就是问题所在,那么我建议您将附件转换为base64,然后在参考文档之后传递它
如果有帮助,请告诉我!
谢谢