Hello,
I set my project a reset password using sendgrid provider and I’ve also tried amazon SES both are working great. But when I modify the template in “settings/email templates” it doesn’t affect the content of the email sent (I receive the default message before modification).
Any ideas ?
Can you give me your Strapi version and what database type you are using? (SQLite, MongoDB, MySQL, MariaDB, PostgreSQL?)
Oh yes sorry about it.
strapi version : 3.2.5
database : PostgreSQL
@DMehaffy
I did some updates, strapi version : 3.3.4
I didn’t figure out how to update the template. I don’t see the changes when i update it.
Also would like to know how to modify <%= URL %> when i’m in production (server.js ?)
thanks for your help
Did you rebuild the admin panel?
@DMehaffy yes I did
And have you configured the public URL in the ./config/server.js (or if your in production/staging, using the ./config/env/*/server.js).
If so can you provide a snippet of your server.js and just swap out your domain for something like example.com
./config/server.js
module.exports = ({ env }) => ({
host: env("HOST", "0.0.0.0"),
port: env.int("PORT", 1337),
admin: {
auth: {
secret: env('ADMIN_JWT_SECRET', process.env.ADMIN_JWT_SECRET),
},
},
});
./config/env/production/server.js
module.exports = ({ env }) => ({
host: env("HOST", process.env.HOST || "0.0.0.0" ),
port: env.int("PORT", process.env.PORT || 4000),
admin: {
auth: {
secret: env('ADMIN_JWT_SECRET', process.env.ADMIN_JWT_SECRET),
},
},
});
I use heroku to deploy my app, if I use “myapp.herokuapp.com” as host variable i got an error.
Do you know where could I find the informations of HOST and PORT ?
and my email config provider : config/plugins.js
module.exports = ({ env }) => ({
email: {
provider: 'sendgrid',
providerOptions: {
apiKey: env('SENDGRID_API_KEY', process.env.SENDGRID_API_KEY),
},
settings: {
defaultFrom: 'hello@test.com',
defaultReplyTo: 'hello@test.com',
},
},
});
Ah yeah we are missing this in our Heroku guide.
In your server.js
(production: ./config/env/production/server.js
)
You need to set the url
key from here: https://strapi.io/documentation/v3.x/concepts/configurations.html#server to your Heroku app URL
In your ./config/env/production/server.js
it should look something like:
module.exports = ({ env }) => ({
host: env("HOST", "0.0.0.0"),
port: env.int("PORT", 1337),
url: env("APP_URL"),
admin: {
auth: {
secret: env('ADMIN_JWT_SECRET'),
},
},
});
Then you can set the APP_URL
environment variable in heroku with their CLI:
heroku config:set HEROKU_URL=$(heroku info -s | grep web_url | cut -d= -f2)
Which will be something like: http://myapp.herokuapp.com
Quick side point as I see there might some confusion as to what the env()
function does in those files. I’d suggest you take a look at this: https://strapi.io/documentation/v3.x/concepts/configurations.html#casting-environment-variables
The env()
function has two parameters, the first is the name of the environment variable process.env.SOME_VAR
such as env('SOME_VAR')
and if that process.env.SOME_VAR
is undefined you pass an alternative.
So env('SOME_VAR', 'defaultValue')
will read and use process.env.SOME_VAR
if it exists, if it’s undefined then it will use defaultValue
instead. There is no need to define the process.env.SOME_VAR
manually, and if you don’t want a default value then you only need: env('SOME_VAR')
Alright, thanks a lot for you explanations, I made some changes about my heroku config. Yes, I definitely misunderstood some parts about env function but now it’s fine thanks to you.
But it seems that I missed something because “forgot email” template has been changed but the email that I received using the provider sendgrid or Amazon was the default message. I had the same behaviour in develop mode.
Did I miss something else about the configuration ?
Thanks a lot for your help.
In the Advanced configuration for the users-permissions plugin, do you have a redirect URL defined?
Yes I did, and I have the good URL displayed in the email and it’s working I can modify my password. But I still have the default template.
udpate strapi version: 3.4.0
the URL displayed is correct &working but the message that I can modify in “settings/email templates” is still the default one (screenshot above - difference between backoffice and email sent by sendgrid). @DMehaffy
Sorry it’s been a while, whats the current issue you are having?
The problem come from the difference between the email template set in backoffice and the email that I got from send grid in my inbox (forgotten password). @DMehaffy
Question, is this for the End-users password reset or the Admin user password reset?
I think I see the issue, if this is for Admin Password resets, the template is static:
My bad it was a misunderstanding between categories of ADMINISTRATION PANEL and USERS & PERMISSIONS PLUGIN.
Because I thought the e-mail template was to modify the forgotten password of the backoffice (strapi) during the authentification step. And get a personify template in my email set from the backoffice.
Thanks for you help !
@DMehaffy
I only just now realized we actually have this documented
In case anyone else has questions (or if you didn’t see it @jeremy )
https://strapi.io/documentation/developer-docs/latest/admin-panel/forgot-password.html
Error 404…