Git Product home page Git Product logo

Comments (29)

matva92 avatar matva92 commented on June 14, 2024 8

Hi ALL, I know this is tooo late haha but if someone reach to same problem, check the from: '[email protected]', should be the email you set in your sendgrid account! Hope that helps

from fullstackreactcode.

Marcol132 avatar Marcol132 commented on June 14, 2024 5

I got the same error. I forgot "await" in the const response.
const response = await this.sgApi.API(request);

from fullstackreactcode.

matva92 avatar matva92 commented on June 14, 2024 3

for the ones that don't want to spend much time on this and just continue, I leave my Mailer.js

const keys = require('../config/keys');
const sgMail = require('@sendgrid/mail');

module.exports = async ({ subject, recipients }, content) => {
  // using SendGrid's v3 Node.js Library
  // https://github.com/sendgrid/sendgrid-nodejs
  sgMail.setApiKey(keys.sendGridKey);
  const formattedRecipients = recipients.map(({email}) => email);
  const msg = {
    to: formattedRecipients,
    from: '[email protected]',
    subject: subject,
    html: content,
  };
  await sgMail.send(msg);
}

and then the call in surveyRouter

    Mailer(survey, surveyTemplate(survey));

This doesn't worked for me. Sad

Check from: '[email protected]' - set it to the email you set in your sendgrid account!

from fullstackreactcode.

zuha-khalid-au3 avatar zuha-khalid-au3 commented on June 14, 2024 3

In Mailer.js at line this.from_email=new helper.Email('[email protected]'); You have to replace this email with the authorized one which you created on sendgrid website.

from fullstackreactcode.

emirfer avatar emirfer commented on June 14, 2024 1

Guys, check your code well and compare it with one in repository. Everything works fine, I got no-reply mail and updated MongoDb!!! You must have made typo somewhere!!!!

from fullstackreactcode.

darda-ergo avatar darda-ergo commented on June 14, 2024 1

Grider used "sendgrid": "^5.1.2" which is now deprecated. Use "@sendgrid/mail" instead . Like this :

Mailer.js File

const keys = require("../config/keys");
const helper = require("@sendgrid/mail").setApiKey(keys.sendGridKey);

const Mailer = (survey, content) => {
  const { subject, recipients } = survey;

  const formatEmail = (emails) => {
    const total = [];
    emails.forEach((item) => {
      total.push(item.email);
    });
    return total;
  };

  const msg = {
    to: formatEmail(recipients),
    from: {
      name: "surveyApp.com",
      email: "Your Varified Email at sengrid",
    },
    subject,
    text: "hello",
    html: content,
  };

  helper.send(msg).then(
    (res) => {
      console.log("email sent", res);
    },
    (error) => {
      console.error(error);

      if (error.response) {
        console.error(error.response.body);
      }
    }
  );
};
module.exports = Mailer; 

surveyRoute.js
Mailer(survey, surveyTemplate(survey));

Thats should or must work ._

from fullstackreactcode.

rostgoat avatar rostgoat commented on June 14, 2024

@StephenGrider do you know why this might be an issue? you didn't seem to have this error in the tutorial and I double checked your code in the repo to make sure mine isnt missing anything

from fullstackreactcode.

rostgoat avatar rostgoat commented on June 14, 2024

looks like the error is thrown inside the try block in surveyRoutes, in the await mailer.send() line..

image

console:

image

removing await from that line allows me to see all the other console logs but the request still fails and throws a 422

from fullstackreactcode.

nitini avatar nitini commented on June 14, 2024

Hi, I'm hitting the exact same problem, unclear how to proceed. Thanks for any information that can be provided!

from fullstackreactcode.

emirfer avatar emirfer commented on June 14, 2024

Be careful! In Mailer.js, path:'v3/mail/send', NOT path:'V3/mail/send'

from fullstackreactcode.

aissayev avatar aissayev commented on June 14, 2024

@rostgoat @nitini
In Mailer.js class please double check that the content variable is not wrapped inside of quotation marks You should have line like this this.body = new helper.Content('text/html', content)
NOT like this this.body = new helper.Content('text/html, content')

Had a similar issue

Hope it helps!

from fullstackreactcode.

NikhileshAS avatar NikhileshAS commented on June 14, 2024

[0] (node:31420) UnhandledPromiseRejectionWarning: SendGridError: Response error [0] at F:\Web Development\MERN\Projects\Feedback\server\node_modules\sendgrid\lib\sendgrid.js:104:23 [0] at IncomingMessage.<anonymous> (F:\Web Development\MERN\Projects\Feedback\server\node_modules\sendgrid-rest\lib\client.js:112:9) [0] at IncomingMessage.emit (events.js:187:15) [0] at endReadableNT (_stream_readable.js:1094:12) [0] at process._tickCallback (internal/process/next_tick.js:63:19) [0] (node:31420) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) [0] (node:31420) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Getting the same error

from fullstackreactcode.

1512413-TrucGiaPhu avatar 1512413-TrucGiaPhu commented on June 14, 2024

triplecheck the send() method in Mailer.js, he added the await there while in the tutorial, he didn't.

from fullstackreactcode.

viso24-7 avatar viso24-7 commented on June 14, 2024

I have an error
Screenshot (244)

from fullstackreactcode.

ignj avatar ignj commented on June 14, 2024

for the ones that don't want to spend much time on this and just continue, I leave my Mailer.js

const keys = require('../config/keys');
const sgMail = require('@sendgrid/mail');

module.exports = async ({ subject, recipients }, content) => {
  // using SendGrid's v3 Node.js Library
  // https://github.com/sendgrid/sendgrid-nodejs
  sgMail.setApiKey(keys.sendGridKey);
  const formattedRecipients = recipients.map(({email}) => email);
  const msg = {
    to: formattedRecipients,
    from: '[email protected]',
    subject: subject,
    html: content,
  };
  await sgMail.send(msg);
}

and then the call in surveyRouter

    Mailer(survey, surveyTemplate(survey));

from fullstackreactcode.

MAfzalKhan1997 avatar MAfzalKhan1997 commented on June 14, 2024

I'm getting same error .. any solution ?

from fullstackreactcode.

harshthakur066 avatar harshthakur066 commented on June 14, 2024

Yes I am also getting same error.

from fullstackreactcode.

harshthakur066 avatar harshthakur066 commented on June 14, 2024

for the ones that don't want to spend much time on this and just continue, I leave my Mailer.js

const keys = require('../config/keys');
const sgMail = require('@sendgrid/mail');

module.exports = async ({ subject, recipients }, content) => {
  // using SendGrid's v3 Node.js Library
  // https://github.com/sendgrid/sendgrid-nodejs
  sgMail.setApiKey(keys.sendGridKey);
  const formattedRecipients = recipients.map(({email}) => email);
  const msg = {
    to: formattedRecipients,
    from: '[email protected]',
    subject: subject,
    html: content,
  };
  await sgMail.send(msg);
}

and then the call in surveyRouter

    Mailer(survey, surveyTemplate(survey));

This doesn't worked for me. Sad

from fullstackreactcode.

ganeshyedla avatar ganeshyedla commented on June 14, 2024

SEND_GRID { [0] errors: [ [0] { [0] message: 'The from address does not match a verified Sender Identity. Mail cannot be sent until this error is resolved. Visit https://sendgrid.com/docs/for-developers/sending-email/sender-identity/ to see the Sender Identity requirements', [0] field: 'from', [0] help: null [0] } [0] ]

You need to setup a Sender Identity, if you are using Free Trial and received access on or after April 6, 2020. For POCs its best to
choose Single Sender Verification. More information here : https://sendgrid.com/docs/for-developers/sending-email/sender-identity/

from fullstackreactcode.

vinc3nati avatar vinc3nati commented on June 14, 2024

Hey I tried all of the methods but still getting this error,
Please help @StephenGrider
Here is my Mailer.js:
https://drive.google.com/file/d/1uGvjVjwrfoa8MJKd81iVj0qWthbvQU_n/view?usp=sharing

client/src/index.js:
https://drive.google.com/file/d/1yw47JKhbve1T8-7oaVuuui2fkHynKhlu/view?usp=sharing

surveyRoutes.js
https://drive.google.com/file/d/1nts2u2Wzb-YEqesXNrk1IOvTIoPvMfDo/view?usp=sharing

Annotation 2020-08-19 202709

from fullstackreactcode.

vinc3nati avatar vinc3nati commented on June 14, 2024

SEND_GRID { [0] errors: [ [0] { [0] message: 'The from address does not match a verified Sender Identity. Mail cannot be sent until this error is resolved. Visit https://sendgrid.com/docs/for-developers/sending-email/sender-identity/ to see the Sender Identity requirements', [0] field: 'from', [0] help: null [0] } [0] ]

You need to setup a Sender Identity, if you are using Free Trial and received access on or after April 6, 2020. For POCs its best to
choose Single Sender Verification. More information here : https://sendgrid.com/docs/for-developers/sending-email/sender-identity/

Hey,
What if we do not create both domain or single sender verification?
Is this necessary to do the domain/single sender verification?

from fullstackreactcode.

NickJoyce-IO avatar NickJoyce-IO commented on June 14, 2024

Hi ALL, I know this is tooo late haha but if someone reach to same problem, check the from: '[email protected]', should be the email you set in your sendgrid account! Hope that helps

Thanks, this is what worked for me.

from fullstackreactcode.

7NithinShetty avatar 7NithinShetty commented on June 14, 2024
this.from_email = new helper.Email("sender mail id");

you just have to use this in Mailer.js.
And make sure that you are using same mail id which you have set as a sender mail id in sendgrid.

from fullstackreactcode.

OluwakemiFasae avatar OluwakemiFasae commented on June 14, 2024

To resolve the issue, I put const response = await this.sgApi.API(request); in a try-catch block. This would also help to reveal if there are other errors you made in your code.

image

from fullstackreactcode.

7NithinShetty avatar 7NithinShetty commented on June 14, 2024

from fullstackreactcode.

7NithinShetty avatar 7NithinShetty commented on June 14, 2024

from fullstackreactcode.

KeyanSong1998 avatar KeyanSong1998 commented on June 14, 2024

I had this issue, my falut was forget to verify sender in sendgrid. Please remeber to verify the sender!!!

from fullstackreactcode.

KeyanSong1998 avatar KeyanSong1998 commented on June 14, 2024

@StephenGrider do you know why this might be an issue? you didn't seem to have this error in the tutorial and I double checked your code in the repo to make sure mine isnt missing anything

I had this issue, my falut was forget to verify sender in sendgrid. Please remeber to verify the sender!!!

from fullstackreactcode.

ybakhshi avatar ybakhshi commented on June 14, 2024

@darda-ergo thank you buddy! it worked out for me after i followed your code !

from fullstackreactcode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.