How to change default emails to have some branding and custom message?
I found https://github.com/appwrite/appwrite/pull/402 but I still have problems where to start.
In my appwrite instance i see only appwrite directory with .env
and docker-compose.yml
files but no templates.
Should I fork appwrite and create separate docker image? How to handle it on a one-click digital ocean droplet?
Any tutorials, articles and comments will be helpful! Thanks
Your Appwrite instance is composed from these parts.
- Production parts: which includes the
docker-compose.yml
and the.env
file - Docker containers: which are containers created from images that holds all the software and underlying system whole together.
- Docker volumes: persisted storage to save you Docker containers data even after the system has rebooted.
In your use case you want to change the Appwrite
image being used for the containers
- appwrite
- appwrite-worker-mails
This is not a simple matter and to achieve that you can:
- Create your own image with different Dockerfile - if you have experience with docker. This is the base file https://github.com/appwrite/appwrite/blob/master/Dockerfile Then you can use this file inside the docker-compose file.
- Mount you code the appwrite containers volumes.,
For example you can set your
app
folder to be your localapp
folder, like such in thedocker-compose.yml
file
volumes:
- ./app:/usr/src/code/app
- ./src:/usr/src/code/src
You can see example of this here: https://github.com/appwrite/appwrite/blob/master/docker-compose.yml
- Edit the Appwrite image locally like you can read here - https://discord.com/channels/564160730845151244/1097119647867863090/1097874270299881492
Then, just restart your docker-compose like so
docker compose up -d
As for the practical step. When editing the emails you'll need to change first the email base template file https://github.com/appwrite/appwrite/blob/master/app/config/locale/templates/email-base.tpl
Then, you'll need to edit. either the part in account.php
that sends the email, like here for example.
https://github.com/appwrite/appwrite/blob/master/app/controllers/api/account.php#L738
Or the worker one here https://github.com/appwrite/appwrite/blob/master/app/workers/mails.php#L33
I use this method to override one or more files without creating a new image:
In the docker-compose.yml
I search the appwrite-worker-mails
service and I do the following:
currently, the volumes section have:
volumes:
- ./app:/usr/src/code/app
- ./src:/usr/src/code/src
I'll override a file as follow
volumes:
- ./app:/usr/src/code/app
- ./src:/usr/src/code/src
- ./app/config//locale/templates/email-base.tpl:./email/email-base.tpl
./email
is a folder in the same path where your docker-compose.yml
file is located
You put your edited file in that folder. The next time you run your containers you'll see the email with the updated template
That way you don't have to maintain a new image.
When you update appwrite you just have to make sure to add this lines again to your docker-compose.yml
file
You can check this guide about mounting volumes in docker to learn more https://www.baeldung.com/ops/docker-mount-single-file-in-volume
Thanks for the help! This is what I was looking for
[Solved] How to setup email templates for self-hosted appwrite?
@Guille @obiwanzenobi it seems it is no longer possible to do so in the latest version 1.3.8 @Steven any leads how to do this without rebuilding the image ?
please create a new post rather than posting on an old thread
@Steven got it.
[SOLVED] How to setup email templates for self-hosted appwrite?
@zjjt could you link your topic here? I can't find it
@obiwanzenobi sure here is the link to it https://discord.com/channels/564160730845151244/1134903901276094514
Thanks
Recommended threads
- Use different email hosts for different ...
Hello, I have 2 projects and i want to be able to set up email templates in the projects. Both projects will have different email host configurations. I see ...
- Migrate from cloud to localhost
Hello everyone. I need to migrate my test project from cloud to localhost, however it seems that this is possible only if a self-hosted appwrite instance it's h...
- Current User is Not authorized
recreating same Thread