From a727175ef1fc00c6ed873940014cad5121733ad5 Mon Sep 17 00:00:00 2001 From: George F Date: Sat, 13 Jun 2020 01:16:25 +0100 Subject: [PATCH] Update docs for domain or email verification Update the docs to reflect the actual functionality. If you are just testing this out in development and follow the instructions either here or inside the sendgrid web app it never mentions you must first verify a "from" domain or single address. You will simply receive a 403 forbidden response on trying to send any mail, including the example email. The error response does contain an error message though by default it won't be visible due to the way node simplifies deeply nested objects in `console.log`, as you can see below. ``` ResponseError: Forbidden at node_modules/@sendgrid/client/src/classes/client.js:133:29 at runMicrotasks () at processTicksAndRejections (internal/process/task_queues.js:97:5) { code: 403, response: { headers: { server: 'nginx', date: 'Fri, 12 Jun 2020 23:54:10 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' }, body: { errors: [Array] } } } ``` By updating the docs, I think some people will benefit including probably [some people who found their way here](https://github.com/sendgrid/sendgrid-nodejs/issues/957) --- packages/mail/README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/mail/README.md b/packages/mail/README.md index c27c39321..31961b048 100644 --- a/packages/mail/README.md +++ b/packages/mail/README.md @@ -46,6 +46,10 @@ You may also use [yarn](https://yarnpkg.com/en/) to install. yarn add @sendgrid/mail ``` +## Verify identity +Verify an email address or domain in the [Sender Authentication tab](https://app.sendgrid.com/settings/sender_auth/senders) +Without this you will receive a 403 forbidden response when trying to send mail. + # Quick Start, Hello Email @@ -58,7 +62,7 @@ const sgMail = require('@sendgrid/mail'); sgMail.setApiKey(process.env.SENDGRID_API_KEY); const msg = { to: 'test@example.com', - from: 'test@example.com', + from: 'test@example.com', // Use the email address or domain you verified above subject: 'Sending with Twilio SendGrid is Fun', text: 'and easy to do anywhere, even with Node.js', html: 'and easy to do anywhere, even with Node.js',