i am using sendgrid mail for sending email below is my code
let mailOptions = {
from: '"ZERTZ." <support@zertz.io>',
to: toAddress,
subject: "Please confirm your Email account",
html: html,
};
this is to send mail
sgMail
.send(mailOptions)
.then(() => {
console.log('Email sent')
})
.catch((error) => {
console.error(error)
})
here is the 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] }
}
change that to below format as email is not proper as sendgrid accept in this format
const msg = {
to,
from: 'support@zertz.io', // Change to your verified sender
subject,
html,
}