npm i strapi-provider-email-sendgrid
Role and permissions setting
But still whenever I register a user Error code 400 is return, also No mail is being sent.
POST /auth/local/register
However the user is created in strapi's Users content type
Console screenshot.
Help me in dealing with it!!
The error management of the email plugin is not good, we have to change it!
This error is probably provided by this code line
To got the correct error, I suggest you to add a console.log
of the err
in your strapi-provider-email-sendgrid
node_module
directly.
I know it's not good to do that but it will be the only way to know the error that you have.
I faced similar issues with the AWS SES email provider from Strapi, so I'll leave my resolution here in case someone googles their way into this question in the future.
That error message is actually thrown by the Sendgrid Strapi email provider in line 58 (https://github.com/strapi/strapi/blob/dae9cfa415881f17ebb95d9ea3887c6a0ae0dca6/packages/strapi-provider-email-sendgrid/lib/index.js#L58).
There's a catch that will swallow exceptions thrown by the Sendgrid library and throw instead this generic message. Here are your options to figure out what the actual error is:
node_modules/strapi-provider-email-sendgrid/lib/index.js
file inside the catch and inspect your standard outputerror.message
string. This might require looking into how Strapi will handle errors thrown inside controllers to make sure it doesn't end up getting lost in the I18N midlleware or other extension points.I had the same problem with strapi/sendgrid. The problem was the fact that the sender was not a verified email in sendgrid.
Step to fix:
I looked for : id: 'Auth.form.error.email.invalid'
in my node_modules.
Then, I logged the error
sendgrid.send(msg, function(err) {
if (err) {
console.log(err.response.body.errors)
reject([{ messages: [{ id: 'Auth.form.error.email.invalid' }] }]);
} else {
resolve();
}
I had the following message inside the error : "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"
So, i went to sendgrid and verified my sender's emails. And it worked :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With