【发布时间】:2019-01-22 05:41:41
【问题描述】:
这是我编写的使用@sendgrid 发送带有附件的电子邮件的代码
const mailOptions = {}
if(mailOptions){
mailOptions.from = 'APP NAME'
mailOptions.to = 'emailId'
mailOptions.subject = 'Subject' // Subject line
//mailOptions.attachments = attachments
mailOptions.text = 'attachments'
}
const sendEmail = await sgMail.send(mailOptions)
但它只发送主题为“无附件”的邮件
取消注释 attachment 行时出现的错误
{ Error: Bad Request
at Request.http [as _callback] (node_modules/@sendgrid/client/src/classes/client.js:124:25)
为什么会发生这种情况,请有人帮助我。
【问题讨论】:
-
您可能会收到来自 SendGrid 的 API 的
400 Bad Request响应。尝试关注 SendGrid 的 error troubleshooting guidelines 以获取他们的节点库。 -
当我不发送附件时,我可以收到电子邮件。
标签: javascript node.js email sendgrid