【问题标题】:cc of SendGrid not working in Azure Mobile appSendGrid 的 cc 在 Azure 移动应用程序中不起作用
【发布时间】:2016-03-01 15:38:06
【问题描述】:

https://azure.microsoft.com/en-us/documentation/articles/store-sendgrid-mobile-services-send-email-scripts/#comment-2539027195 此处所述,似乎只有以下语法在 Azure 移动应用程序中有效

sendgrid.send({ to: '电子邮件地址', 发件人:'发件人地址', 主题:'新的待办事项', text: '添加了一个新的待办事项:' + item.text },函数(成功,消息){ 如果(!成功){ 控制台.错误(消息); } });

从上面可以看出,回调函数传入了成功参数,而 GitHub 中的 node.js 模块 (https://github.com/sendgrid/sendgrid-nodejs) 则传入了错误参数。因此,Azure 移动服务似乎没有使用相同的模块或版本,那里也存在一些断开连接。

sendgrid.send(email, function(err, message) { 如果(错误){ 控制台.错误(消息); } });

【问题讨论】:

  • 能否分享您的相关代码来分析问题?
  • sendgrid.send({ to: 'email-address', cc: 'email-address', from: 'from-address', subject: '新的待办事项', text: '一些文本' }, function(success, message) { if (!success) { console.error(message); } });

标签: node.js azure azure-mobile-services


【解决方案1】:

来自 Azure 移动论坛上的帖子:

因为移动服务中 SendGrid 的默认版本是“0.2.4”,比最新版本低很多。

有两种方法可以尝试在移动服务中更新 sendgrid 的版本:

1、登录您的移动服务的kudu控制台站点,利用站点上的cmdlet在线修改您的移动服务应用程序的package.json文件,例如:

"sendgrid":"^2.0.0",

在“依赖项”下关闭。然后在 cmdlet 中运行命令:npm update 以更新移动服务中的 sendgrid sdk。 Kudu 控制台站点 URL 应为 https://<your_mobile_service_name>.scm.azure-mobile.net/DebugConsole

2、可以参考https://azure.microsoft.com/en-us/documentation/articles/mobile-services-store-scripts-source-control/#use-npm自己部署sendgrid sdk,使用

var sendgrid  = require('sendgrid')('YOUR_SENDGRID_API_KEY'); 

在您的代码中实现 sendgrid。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-05-21
    • 2016-12-27
    • 1970-01-01
    • 1970-01-01
    • 2016-08-24
    • 1970-01-01
    • 2021-09-09
    相关资源
    最近更新 更多