首页 > 解决方案 > Strapi 使用 SendGrid“内部错误”发送电子邮件

问题描述

我正在尝试使用 SendGrid 发送电子邮件。但是,它不起作用。我将 SendGrip 配置为

Setup->Guide->Integrate->Web API->Node.js and get "myKeyFromSendGrid"

我设置了文件 config/plugins.js

module.exports = ({ env }) => ({   // ...   email: {     provider: "sendgrid",     providerOptions: {       apiKey: env(         "myKeyFromSendGrid"       ),     },     settings: {       defaultFrom: "test@test.com",       defaultReplyTo: "no-reply@test.com",     },   },   // ... }); 

我启动了我的 Strapi 服务器,并在角色和权限中配置了电子邮件发送给公众。然后,我去 Postman 并使用以下内容创建一个新的 POST 请求“ http://localhost:1337/email ”:

{

  "to": "test@example.com",

  "from": "test@example.com",

  "subject": "Sending with Twilio SendGrid is Fun",

  "text": "and easy to do anywhere, even with Node.js",

  "html": "<strong>and easy to do anywhere, even with Node.js</strong>"

}

但我不断收到来自 Postman 和 Strapi Debug 的“内部服务器错误”

  AssertionError [ERR_ASSERTION]:无法包装非错误对象

  在 Function.boomify (C:\Users\GustavoRangel\Documents\Development\sandbox\personal_blog\server\node_modules\boom\lib\index.js:107:14)

      在 formatBoomPayload (C:\Users\GustavoRangel\Documents\Development\sandbox\personal_blog\server\node_modules\strapi\lib\middlewares\boom\index.js:47:22) 在 C:\Users\GustavoRangel\Documents\Development\沙箱\personal_blog\server\node_modules\strapi\lib\middlewares\boom\index.js:84:36

      在 processTicksAndRejections (internal/process/task_queues.js:97:5)

知道我在做什么错吗?我正在使用 Strapi v3.0.1

标签: node.jsemailsendgridstrapi

解决方案


推荐阅读