Back

[SOLVED] How to setup email templates for self-hosted appwrite?

  • 1
  • General
  • Locale
  • Self Hosted
obiwanzenobi
5 Jun, 2023, 08:13

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

TL;DR
The user wanted to know how to set up email templates for self-hosted Appwrite. Another user provided a solution: - Edit the `docker-compose.yml` file of the Appwrite instance. - Find the `appwrite-worker-mails` service and add the following volume: - `./app/config/locale/templates/email-base.tpl:./email/email-base.tpl` - Create a new folder named `email` in the same path as the `docker-compose.yml` file. - Place the edited email template file in the `email` folder. - Restart the containers using `docker compose up -d`. This way, the email templates can
Binyamin
5 Jun, 2023, 12:56

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:

  1. 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.
  2. Mount you code the appwrite containers volumes., For example you can set your app folder to be your local app folder, like such in the docker-compose.yml file
TypeScript
    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

  1. 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

TypeScript
docker compose up -d
Binyamin
5 Jun, 2023, 13:02

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

Guille
5 Jun, 2023, 13:15

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:

TypeScript
 volumes:
      - ./app:/usr/src/code/app
      - ./src:/usr/src/code/src

I'll override a file as follow

TypeScript
 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

obiwanzenobi
5 Jun, 2023, 13:19

Thanks for the help! This is what I was looking for

obiwanzenobi
5 Jun, 2023, 13:20

[Solved] How to setup email templates for self-hosted appwrite?

zjjt
28 Jul, 2023, 09:15

@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 ?

Drake
28 Jul, 2023, 17:23

please create a new post rather than posting on an old thread

zjjt
28 Jul, 2023, 17:24

@Steven got it.

Guille
29 Jul, 2023, 13:33

[SOLVED] How to setup email templates for self-hosted appwrite?

obiwanzenobi
29 Jul, 2023, 17:35

@zjjt could you link your topic here? I can't find it

zjjt
29 Jul, 2023, 17:43
obiwanzenobi
29 Jul, 2023, 17:45

Thanks

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more