ale*_*dap 13 email node.js http-status-code-403 sendgrid express
我在 node js 项目中使用 Send grid 发送了一封非常简单的电子邮件。但是我得到了一个 403 Forbidden 错误。API 密钥具有完全访问权限。该代码也已正确集成,因为我使用了另一个帐户的另一个 API 密钥,并且它运行良好。
有什么建议?
小智 15
该错误存在的原因是消息中“发件人”字段中的电子邮件地址(在您的 nodejs 代码中,将使用 sendgrid 发送)未通过 sendgrid 验证。仅将该电子邮件地址放在由 sendgrid 明确验证的“发件人”字段中。
要验证您的发件人电子邮件地址以便能够发送电子邮件,请参阅以下链接:-
https://sendgrid.com/docs/ui/sending-email/sender-verification
希望这可以帮助。
(可能有关于域名的更多问题,请正确阅读链接,他们有关于使用 gmail.com 地址的警告,您可以忽略)
ResponseError: Forbidden
at node_modules/@sendgrid/client/src/classes/client.js:133:29
at processTicksAndRejections (internal/process/task_queues.js:93:5) {
code: 403,
response: {
headers: {
server: 'nginx',
date: 'Sat, 10 Oct 2020 17:22:02 GMT',
'content-type': 'application/json',
'content-length': '281',
connection: 'close',
'access-control-allow-origin': 'https://sendgrid.api-docs.io',
'access-control-allow-methods': 'POST',
'access-control-allow-headers': 'Authorization, Content-Type, On-behalf-of, x-sg-elas-acl',
'access-control-max-age': '600',
'x-no-cors-reason': 'https://sendgrid.com/docs/Classroom/Basics/API/cors.html'
},
Run Code Online (Sandbox Code Playgroud)
所以意思是from: address这里
const msg = {
to: 'recepient@email.com',
from: 'sender@email.com', //this is the address that needs to be verified by sendgrid
subject: 'Sending from Sendgrid',
text: 'here is the test from node',
html: `<strong> Here is the order #${orderNumber} user: ${user} </strong>`,
}
Run Code Online (Sandbox Code Playgroud)
以下是如何验证它 https://sendgrid.com/docs/ui/sending-email/sender-verification/
请参阅下面的屏幕截图:
Sea*_*n C -3
[Tulio Faria] 通过在他的 Sendgrid 帐户上执行“单一发件人身份验证”解决了这个问题。
不久前我也遇到了类似的问题。帮助我解决这个问题的是转到设置> API 密钥,然后将我正在使用的密钥的设置更改为完全访问权限。

| 归档时间: |
|
| 查看次数: |
9718 次 |
| 最近记录: |