Open rostgoat opened 6 years ago
@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
looks like the error is thrown inside the try block in surveyRoutes
, in the await mailer.send()
line..
console:
removing await
from that line allows me to see all the other console logs but the request still fails and throws a 422
Hi, I'm hitting the exact same problem, unclear how to proceed. Thanks for any information that can be provided!
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!!!!
Be careful! In Mailer.js, path:'v3/mail/send', NOT path:'V3/mail/send'
@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!
I got the same error. I forgot "await" in the const response.
const response = await this.sgApi.API(request);
[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
triplecheck the send() method in Mailer.js, he added the await there while in the tutorial, he didn't.
I have an error
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: 'no-reply@emaily.com',
subject: subject,
html: content,
};
await sgMail.send(msg);
}
and then the call in surveyRouter
Mailer(survey, surveyTemplate(survey));
I'm getting same error .. any solution ?
Yes I am also getting same error.
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: 'no-reply@emaily.com', 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
Hi ALL, I know this is tooo late haha but if someone reach to same problem, check the from: 'no-reply@emaily.com', should be the email you set in your sendgrid account! Hope that helps
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: 'no-reply@emaily.com', 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: 'no-reply@emaily.com' - set it to the email you set in your sendgrid account!
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/
In Mailer.js at line this.from_email=new helper.Email('no-reply@emaily.com');
You have to replace this email with the authorized one which you created on sendgrid website.
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
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?
Hi ALL, I know this is tooo late haha but if someone reach to same problem, check the from: 'no-reply@emaily.com', should be the email you set in your sendgrid account! Hope that helps
Thanks, this is what worked for me.
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.
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.
Since I'm in India I had to use INR instead of USD. it worked.
On Thu, 25 Mar 2021 at 20:26, OluwakemiFasae @.***> wrote:
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: image] https://user-images.githubusercontent.com/11194167/112493082-23c04480-8d82-11eb-908e-19424383cdab.png
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/StephenGrider/FullstackReactCode/issues/30#issuecomment-806898306, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQIH66ULFAVSGT6JT3KQYILTFNFKPANCNFSM4FC7EFWA .
Hii Stephen, But now I'm facing a different problem. It's been more than 15days i'm not able to solve this error. For the last 3weeks i'm asking you for help in udemy chat. But i didn't get any response from your side. Please help me out.
Problem: After i click on yes/no from my mail, i'm not getting anything in return to my console as in course. I have noticed that there is no activity there in the "activity feed" of sendgrid. Here is my repository: https://github.com/7NithinShetty/feedback_app Please help me out with this.
Thanks & Regards, Nithin Shetty
On Sat, 10 Apr 2021 at 19:22, Nithin Shetty @.***> wrote:
Since I'm in India I had to use INR instead of USD. it worked.
On Thu, 25 Mar 2021 at 20:26, OluwakemiFasae @.***> wrote:
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: image] https://user-images.githubusercontent.com/11194167/112493082-23c04480-8d82-11eb-908e-19424383cdab.png
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/StephenGrider/FullstackReactCode/issues/30#issuecomment-806898306, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQIH66ULFAVSGT6JT3KQYILTFNFKPANCNFSM4FC7EFWA .
I had this issue, my falut was forget to verify sender in sendgrid. Please remeber to verify the sender!!!
@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!!!
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 .__
@darda-ergo thank you buddy! it worked out for me after i followed your code !
stack trace
did anyone have this issue when trying to send the email through axios?