Node JS: Sendgrid Mail 403 'Forbidden' error Node JS: Sendgrid Mail 403 'Forbidden' error express express

Node JS: Sendgrid Mail 403 'Forbidden' error


The error exists as the email address in the "from" field in the message(in your nodejs code,, to be sent using sendgrid) is not verified by sendgrid. Only put that email address in the "from" field which is explicitely verified by sendgrid.

To verify your sender email address to be able to send emails, refer to the link below:-

https://sendgrid.com/docs/ui/sending-email/sender-verification

Hope this helps.

(There could be further issues regarding domain name, read the link properly, they have a warning regarding use of gmail.com addresses, you can ignore that)


Pasting the entire ERROR here

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'    },

Here is the solution to further expand on what @Aman answered above.

  • You have to verify the email address you are sending from.

so meaning the from: address here

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>`,}

Here is how to verify ithttps://sendgrid.com/docs/ui/sending-email/sender-verification/

See screenshot below:

enter image description here


To fix this error you need go to perform SendGrid Sender Authentication for your sender email.

To do this, You need to login to your SendGrid Dashboard and visit Sender Authentication which is under the Settings dropdown.

There are 2 Types of Sender Authentication

  1. Domain Authentication // recommended
  2. Single Sender Verification

1 Domain Authentication
IF you allow SendGrid to authenticate your domain e.g. webapp.com
THEN you will be able to successfully send an email with your SendGrid API KEY if the email from key matches the verified domain from: *@webapp.com

2 Single Sender Authentication
This is another option where you verify a single email e.g. person@email.com.
Which will then allow you to send out emails from: person@email.com via your SendGrid API KEY