[英]Why sendgrid sending mails only in queue?
我首先在nodejs
sendgrid
這是我的簡單發送消息:
const sendgrid = require('@sendgrid/mail')
sendgrid.setApiKey(process.env.SENDGRID_PASSWORD)
const message = {
from: 'feruzatamyradow@mail.ru',
to: "rozumyratamyradow@gmail.com",
subject: 'Hello',
text: 'Hello',
html: '<h1>Hello</h1>'
}
sendgrid.send(message)
.then((res)=>{
console.log("Email sent...", res);
})
.catch(err=>{
console.error(err);
})
當我運行它時,我得到了這個:
Email sent... [
Response {
statusCode: 202,
body: '',
headers: {
server: 'nginx',
date: 'Wed, 07 Sep 2022 10:00:37 GMT',
'content-length': '0',
connection: 'close',
'x-message-id': 'leN_4o2nSIy9bJ8UKJ9L9A',
'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',
'strict-transport-security': 'max-age=600; includeSubDomains'
}
},
''
]
當我展示這個 email 時沒有任何郵件消息。 當我檢查 sendgrid 我看到這個:
如何解決?
當您向 SendGrid 提交 email 消息時,SendGrid 接受您的 email 消息並將其放入隊列中,然后 SendGrid 以 HTTP 202 響應響應您。
SendGrid 持續處理隊列中的消息,執行諸如渲染模板(例如替換標簽、動態 Email 模板)、檢查抑制和取消訂閱、生成點擊跟蹤鏈接(如果啟用)等操作。
使用隊列是為實現最大規模而做出的架構決策。 否則,SendGrid 將無法發送數萬億封電子郵件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.