Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

email templates path not working #22473

Closed
sharkfin009 opened this issue May 12, 2024 · 21 comments
Closed

email templates path not working #22473

sharkfin009 opened this issue May 12, 2024 · 21 comments

Comments

@sharkfin009
Copy link
Contributor

sharkfin009 commented May 12, 2024

Describe the Bug

This seems like a really simple issue but it has me stuck. I have an endpoint extension that sends an email and it can't seem to read the template files. I am on the latest version and I did see this in breaking changes:


Moved Email Templates Out of Extensions
Email Templates are no longer considered an extension type as of this release. The templates extensions directory must be migrated.

Place email templates in the ./templates directory, or set the new location in the EMAIL_TEMPLATES_PATH environment variable.

I have done exactly this, trying the ./templates option and also trying setting a new location in the .env variable.

Error response when the endpoint receives a request :
directus | DirectusError: Invalid payload. Template "enquiry" doesn't exist.
directus | at MailService.renderTemplate (file:///directus/node_modules/.pnpm/@directus+api@file+api_@aws-sdk+client-sso-oidc@3.569.0_@aws-sdk+client-sts@3.569.0_@types+no_odrjvwlnfqlgyznoalys6xyvne/node_modules/@directus/api/dist/services/mail/index.js:65:19)
directus | at async MailService.send (file:///directus/node_modules/.pnpm/@directus+api@file+api_@aws-sdk+client-sso-oidc@3.569.0_@aws-sdk+client-sts@3.569.0_@types+no_odrjvwlnfqlgyznoalys6xyvne/node_modules/@directus/api/dist/services/mail/index.js:48:20)

To Reproduce

use the mailService.send method , passing in options including template.name where name is an existing .liquid filename inside ./templates

Directus Version

10.11.0

Hosting Strategy

Self-Hosted (Docker Image)

@sharkfin009
Copy link
Contributor Author

hmm, i have forked the directus repo to try to reproduce the issue and I haven't succeeded, ie template being targetted fine.
But I wish I knew why it was happening in my project

@sharkfin009
Copy link
Contributor Author

sharkfin009 commented May 12, 2024

ah! I figured it out. Now that the templates directory is not inside the extensions directory, it will need it's own docker volume ... facepalm ;)
Should this be added to the docs ? Will do a pull request.

@PhilipZi
Copy link

dude how did you solve it? we have the same issue. Cant read access the custom-template.liquid

@PhilipZi
Copy link

we tried ./templates and extensions/templates and restart the docker

@sharkfin009
Copy link
Contributor Author

hey! in your docker-compose.yml, your directus container must have this ( ie add the templates volume):
volumes:
- ./extensions:/directus/extensions
- ./templates:/directus/templates

@PhilipZi
Copy link

big thanks for your reply! And you added the folder templates yourself and created a base.liquid etc?

@sharkfin009
Copy link
Contributor Author

pleasure! yes i did

@PhilipZi
Copy link

can you send me a structure of your base.liquid?

@PhilipZi
Copy link

Bildschirmfoto 2024-05-15 um 11 29 06
Uploading Bildschirmfoto 2024-05-15 um 11.29.43.png…

look this is my structure for the folders
still not working

@PhilipZi
Copy link

Bildschirmfoto 2024-05-15 um 11 29 43

@PhilipZi
Copy link

Bildschirmfoto 2024-05-15 um 11 32 09

@PhilipZi
Copy link

Bildschirmfoto 2024-05-15 um 11 32 37

thats my followup.template.liquid file... and it wont find or access this one. I have no idea anymore...

@PhilipZi
Copy link

i get this error
"name": "DirectusError",
"extensions": {
"reason": "Template "followup-template" doesn't exist"
},
"code": "INVALID_PAYLOAD",
"status": 400

@sharkfin009
Copy link
Contributor Author

hmm... you have rebuilt the docker-compose?

@sharkfin009
Copy link
Contributor Author

I'm not useing a base template, but thats not relevant really. Are you on the latest version? 10.11.0?

@PhilipZi
Copy link

yes we did we found the error now!
we also have to add this to the docker compose.yml
Bildschirmfoto 2024-05-15 um 11 35 56

@PhilipZi
Copy link

working now!

@sharkfin009
Copy link
Contributor Author

sharkfin009 commented May 15, 2024

AH yes, forgot about that, although i would have thought it would default . Anyhow... Cool man glad its working. Always good to know I'm not the only one tearing my hair out about these things lol

@PhilipZi
Copy link

bro the docu is so bad about this... i am a big fan of directus but this stuff is really not fair to configure... actually so simple but if you dont know you dont know...
happy we are a bit a head now! All the best and thanks for reaching out and you did help us!

@sharkfin009
Copy link
Contributor Author

I know, the docs are behind the latest version in many places. But i can imagine it's really hard for the guys to keep the docs up to date along with all the issues. I did a docs PR for the added templates volume in the example docker-compose file, and it was merged in. Hoping to find time to do more docs PRs

@PhilipZi
Copy link

good job mate! your are right

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants