[英]How to send email using azure JavaScript function?
[英]Javascript Azure Function to send email using SendGrid
我想使用SendGrid从Azure函数(Javascript)发送电子邮件。 我做了以下
module.exports = function (context, myQueueItem) {
var message = {
"personalizations": [ { "to": [ { "email": "testto@test.com" } ] } ],
from: { email: "testfrom@test.com" },
subject: "Azure news",
content: [{
type: 'text/plain',
value: myQueueItem
}]
};
context.done(null, message);
};
但是电子邮件没有发送。 请提供一些指示
我最初会测试并面对相同的问题。
请更改为context.done(null,{message});
您可以尝试使用以下代码:
module.exports = function (context, order) {
context.log(order);
var message = {
"personalizations": [ { "to": [ { "email": "testto@gmail.com" } ] } ],
from: { email: "testfrom@gmail.com" },
subject: "Azure news",
content: [{
type: 'text/plain',
value: order
}]
};
context.done(null, {message});
};
并且funtion.json文件是:
{
"bindings": [
{
"type": "queueTrigger",
"name": "order",
"direction": "in",
"queueName": "samples-orders"
},
{
"type": "sendGrid",
"name": "message",
"direction": "out",
"apiKey": "mysendgridkey",
"from": "testfrom@gmail.com",
"to": "testto@gmail.com"
}
],
"disabled": false
}
我在这里使用Gmail,因此我也允许安全性较低的应用程序:开
单击此链接 ,可以对其进行配置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.