Sendgrid在nodejs中发送邮件403响应禁止错误

Sendgrid send mail in nodejs 403 response forbidden error

我正在使用 sendgrid mail 发送电子邮件下面是我的代码

let mailOptions = {
    from: '"ZERTZ." <support@zertz.io>',
    to: toAddress,
    subject: "Please confirm your Email account",
    html: html,
  };

这是发邮件

sgMail
  .send(mailOptions)
  .then(() => {
    console.log('Email sent')
  })
  .catch((error) => {
    console.error(error)
  })

这里是错误

ResponseError: Forbidden
    at D:\OFFICE\Zertz\Web Application\Web app\Zertz-webapp\node_modules\@sendgrid\client\src\classes\client.js:146:29 
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  code: 403,
  response: {
    headers: {
      server: 'nginx',
      date: 'Tue, 18 Jan 2022 10:15:23 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',
      'strict-transport-security': 'max-age=600; includeSubDomains'
    },
    body: { errors: [Array] }
  }

将其更改为以下格式,因为电子邮件不正确,因为 sendgrid 接受这种格式

const msg = {
    to,
    from: 'support@zertz.io', // Change to your verified sender
    subject,
    html,
}