Open Paratron opened 2 years ago
Hi, If the issue is open, I want to work on it. :)
Up up +++
I am having this major issue when trying to send confirmation e-mail on register with SendGrid
"@strapi/provider-email-sendgrid": "^4.6.1",
email: {
config: {
provider: 'sendgrid',
providerOptions: {
apiKey: env('SENDGRID_API_KEY'),
},
settings: {
defaultFrom: 'my verified sendgrid email',
defaultReplyTo: 'my verified sendgrid email',
testAddress: '*******',
},
},
}
But strapi using Administration Panel no-reply@strapi.io as from email instead my verified sendgrid email in email.settings.defaulfFrom at plugins.js and it returns 400 Error but still creates the user.
It works if I change this
from: from || settings.defaultFrom,
to
from: settings.defaultFrom,
in node_modules/@strapi/provider-email-sendgrid/lib/index.js
Using this method with Nuxt 3
"@nuxtjs/strapi": "^1.7.1",
// Strapi Register Method
const { register } = useStrapiAuth();
You need to set your from mail inside the strapi admin panel settings as a workaround.
You need to set your from mail inside the strapi admin panel settings as a workaround.
Which version you are using? Because there is no such setting in the admin panel. Even tho its not clear and doesnt exists on the docs
Granted, UX wise its super strange but you need to go to the Email Templates section. Each template has its own email send address for some reason - and that defaults to no-reply@strapi.io
Granted, UX wise its super strange but you need to go to the Email Templates section. Each template has its own email send address for some reason - and that defaults to no-reply@strapi.io
yes I think this is exactly what you were trying to say in your issue description :)
Up up +++
I am having this major issue when trying to send confirmation e-mail on register with SendGrid
"@strapi/provider-email-sendgrid": "^4.6.1",
email: { config: { provider: 'sendgrid', providerOptions: { apiKey: env('SENDGRID_API_KEY'), }, settings: { defaultFrom: 'my verified sendgrid email', defaultReplyTo: 'my verified sendgrid email', testAddress: '*******', }, }, }
But strapi using Administration Panel no-reply@strapi.io as from email instead my verified sendgrid email in email.settings.defaulfFrom at plugins.js and it returns 400 Error but still creates the user.
It works if I change this
from: from || settings.defaultFrom,
to
from: settings.defaultFrom,
in node_modules/@strapi/provider-email-sendgrid/lib/index.js
Using this method with Nuxt 3
"@nuxtjs/strapi": "^1.7.1",
// Strapi Register Method const { register } = useStrapiAuth();
Same issue, it just doesn't seem to work. Here's what I did:
npm install @strapi/provider-email-sendgrid --save
- Update my .config/plugins.js file
module.exports = ({ env }) => ({ // ... email: { config: { provider: 'sendgrid', // For community providers pass the full package name (e.g. provider: 'strapi-provider-email-mandrill') providerOptions: { apiKey: env('SENDGRID_API_KEY'), }, settings: { defaultFrom: 'verifiedmail@myorg.com', defaultReplyTo: 'verifiedmail@myorg.com', testAddress: 'verifiedmail@myorg.com', }, }, }, // ... });
But after following these steps, here's the weird thing:
- It still doesn't show my email settings in configuration
![image](https://user-images.githubusercontent.com/23653713/228090275-5488513b-f227-4eb0-99ef-0acfe20824ea.png)
- When I search for providers, it shows that sendgrid is installed
![image](https://user-images.githubusercontent.com/23653713/228090388-1f80da05-0af4-419b-8d1f-e079e443bd0a.png)
I found a bug in provider-email-sendgrid which caused very confusing error responses when trying to create a user.
Describe the bug
I was trying to register a new user through the REST API. The API response was status 400: Forbidden. The weird thing: a database record for the new user was created! No confirmation mail was sent out.
At first, I thought it could not be the email plugin because when I hit the "Send test mail" button in the admin UI, I received a test mail just fine.
In the end, it still turned out to be the sendgrid email plugin. What I did not take into consideration was that even tough in
/config/plugins.js
I configured adefaultFrom
address, this is eventually overridden through a default address stored with the E-Mail Address Confirmation template. There isno-reply@strapi.io
set by default which caused sendgrid to refuse to send the mail because thats not a valid sender address for my account.Now the problem is that in fact, sendgrid response with
400: forbidden
here, its still a bug that THIS EXACT error bubbles up until the REST endpoint of strapi ultimatively returns this to the browser. There is nothing in the console of the strapi node process.The plugin throws the error object, here: https://github.com/strapi/strapi/blob/main/packages/providers/email-sendgrid/lib/index.js#L29
However, the code upwards looks only for the
message
property of the error, which is in fact "forbidden". But there is much more information here:The sendgrid plugin should actually look into the error object coming from sendgrid and at least provide some meaningful message in the node console instead of throwing the whole object upwards to code which is not aware of the additional information inside the
response
property.So what I think should be done (thats full up to you tough):
no-reply@strapi.io
as default sender address from the email templates. Just leave it empty so the configured default address from the config file can be used. This would boost UX enormous!Steps to reproduce the behavior
Expected behavior
The data of the created user should be sent in the REST api response, even tough no confirmation mail could be sent. There should be meaningful error messages in the Strapi process logs.