Javascript Azure函数使用SendGrid发送电子邮件

编程入门 行业动态 更新时间:2024-10-21 09:18:42
本文介绍了Javascript Azure函数使用SendGrid发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想使用SendGrid从Azure函数(Javascript)发送电子邮件.我已经完成了以下

I want to send emails from an Azure function (Javascript) using SendGrid. I have done the following

  • 为SendGrid API密钥创建了一个新的AppSettings
  • Azure功能的SendGrid输出绑定集
  • 以下是我的Azure功能
  • module.exports = function (context, myQueueItem) { var message = { "personalizations": [ { "to": [ { "email": "testto@test" } ] } ], from: { email: "testfrom@test" }, subject: "Azure news", content: [{ type: 'text/plain', value: myQueueItem }] }; context.done(null, message); };

    但是电子邮件没有发送.请提供一些指针

    But email is not getting send. Please provide some pointers

    推荐答案

    我最初测试并面临同样的问题.

    I test and face the same problem with you initially.

    请更改为 context.done(null,{message});

    您可以尝试使用以下代码:

    You could try to use the following code:

    module.exports = function (context, order) { context.log(order); var message = { "personalizations": [ { "to": [ { "email": "testto@gmail" } ] } ], from: { email: "testfrom@gmail" }, subject: "Azure news", content: [{ type: 'text/plain', value: order }] }; context.done(null, {message}); };

    funtion.json文件为:

    And the funtion.json file is:

    { "bindings": [ { "type": "queueTrigger", "name": "order", "direction": "in", "queueName": "samples-orders" }, { "type": "sendGrid", "name": "message", "direction": "out", "apiKey": "mysendgridkey", "from": "testfrom@gmail", "to": "testto@gmail" } ], "disabled": false }

    我在这里使用Gmail,所以我也允许安全性较低的应用程序:打开

    Here I use the Gmail, so I also Allow less secure apps: ON

    点击此链接,即可对其进行配置.

    Click this link, you could configure it.

    更多推荐

    Javascript Azure函数使用SendGrid发送电子邮件

    本文发布于:2023-11-06 06:38:43,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1562964.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:函数   发送电子邮件   Javascript   Azure   SendGrid

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!