我想在我的lb4应用程序中使用Sendinblue api来发送邮件,但是我在附件中遇到了一些困难,我能得到一个链接sendinblue api V3与loopback4 (nodejs)的简单示例吗?谢谢
发布于 2020-08-24 18:40:33
我按照他们的参考文档中提到的步骤运行了下面的脚本!
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,然后按照他们的参考文档传递它。
如果有帮助,请告诉我!谢谢
https://stackoverflow.com/questions/60651587
复制相似问题