SMTP Templates #178

Closed
opened 2026-02-04 18:16:06 +03:00 by OVERLORD · 11 comments
Owner

Originally created by @dirtycajunrice on GitHub (Jan 7, 2019).

The SMTP invitation email works like a charm, but i dont see anywhere that i can change the from-name/subject/body. Is this available currently?

"Join bitwarden_rs" From "Bitwarden-rs" and "you have been invited to join the bitwarden_rs organization" bits are a bit dreary when inviting someone to something and you can brand.

Originally created by @dirtycajunrice on GitHub (Jan 7, 2019). The SMTP invitation email works like a charm, but i dont see anywhere that i can change the from-name/subject/body. Is this available currently? "Join bitwarden_rs" From "Bitwarden-rs" and "you have been invited to join the bitwarden_rs organization" bits are a bit dreary when inviting someone to something and you can brand.
OVERLORD added the enhancement label 2026-02-04 18:16:06 +03:00
Author
Owner

@njfox commented on GitHub (Jan 7, 2019):

Yeah, the invitation emails are a bit bland right now. We could add support for custom templates in the future but at the moment the email contents are hardcoded in /src/mail.rs. In the meantime you can modify those and build from source to be able to customize them.

I’d welcome any contributions or suggestions for email templates because unfortunately I am pretty bad at visual design/branding stuff.

@njfox commented on GitHub (Jan 7, 2019): Yeah, the invitation emails are a bit bland right now. We could add support for custom templates in the future but at the moment the email contents are hardcoded in `/src/mail.rs`. In the meantime you can modify those and build from source to be able to customize them. I’d welcome any contributions or suggestions for email templates because unfortunately I am pretty bad at visual design/branding stuff.
Author
Owner

@dirtycajunrice commented on GitHub (Jan 7, 2019):

I dont know rust so how you actually implement it would be your thing, but i can draw up a template in the morning that has variables. You could save the template in /data somewhere and call it instead of the static bits. Since it wouldnt be part of the upstream i would assume you would need to put the configuration options in either env vars as below or template and the template can reference vars or be static based on how they use the vars (minus the subject and from name).

-e SMTP_LOGO=/data/smtp_template/logo.png
-e SMTP_SUBJECT="Join My Password Manger!"
-e SMTP_FROM_NAME="John Doe's Password Manager"
-e SMTP_TEMPLATE=/data/smtp_template/smtp_template.html

Edit: snmp to smtp. Oof it was late last night!

@dirtycajunrice commented on GitHub (Jan 7, 2019): I dont know rust so how you actually implement it would be your thing, but i can draw up a template in the morning that has variables. You could save the template in /data somewhere and call it instead of the static bits. Since it wouldnt be part of the upstream i would assume you would need to put the configuration options in either env vars as below or template and the template can reference vars or be static based on how they use the vars (minus the subject and from name). ``` -e SMTP_LOGO=/data/smtp_template/logo.png -e SMTP_SUBJECT="Join My Password Manger!" -e SMTP_FROM_NAME="John Doe's Password Manager" -e SMTP_TEMPLATE=/data/smtp_template/smtp_template.html ``` Edit: snmp to smtp. Oof it was late last night!
Author
Owner

@dani-garcia commented on GitHub (Jan 7, 2019):

In the future, we might implement the rest of the email functionality, so I think it would be better to think of another way to save those changes, otherwise we'd end with 100 different variables for all the subjects and bodies combined with all the email types, like invites, invite notificacions, two factor tokens, email validations...

I think we could have a template folder, where each email would get it's own file, and the file could possibly be divided in sections for each part of the email, something like:

{{ owner_name }} has invited you to join {{ org_name }}!
----------------
<html>
.. Body template here, with logos, styles and stuff
</html>

That way, each email would be separated in it's own thing. We'll provide a good default option and we'll allow the user to change the templates dir like we allow for the other directories.

For templating, the most used rust libraries seem to be tera and handlebars, so we should probably use one of those

SMTP_FROM_NAME would probably be the same for all emails, so we should definitely add that as an env option next to SMTP_FROM

@dani-garcia commented on GitHub (Jan 7, 2019): In the future, we might implement the rest of the email functionality, so I think it would be better to think of another way to save those changes, otherwise we'd end with 100 different variables for all the subjects and bodies combined with all the email types, like invites, invite notificacions, two factor tokens, email validations... I think we could have a template folder, where each email would get it's own file, and the file could possibly be divided in sections for each part of the email, something like: ``` {{ owner_name }} has invited you to join {{ org_name }}! ---------------- <html> .. Body template here, with logos, styles and stuff </html> ``` That way, each email would be separated in it's own thing. We'll provide a good default option and we'll allow the user to change the templates dir like we allow for the other directories. For templating, the most used rust libraries seem to be [tera ](https://crates.io/crates/tera) and [handlebars](https://crates.io/crates/handlebars), so we should probably use one of those `SMTP_FROM_NAME` would probably be the same for all emails, so we should definitely add that as an env option next to `SMTP_FROM`
Author
Owner

@dirtycajunrice commented on GitHub (Jan 7, 2019):

Thats EXACTLY what i was thinking of! My initial thought were jinja2 but i didnt know what worked with rust. Thanks @dani-garcia

@dirtycajunrice commented on GitHub (Jan 7, 2019): Thats EXACTLY what i was thinking of! My initial thought were jinja2 but i didnt know what worked with rust. Thanks @dani-garcia
Author
Owner

@dani-garcia commented on GitHub (Jan 13, 2019):

I created a new branch with initial support for templates:
https://github.com/dani-garcia/bitwarden_rs/tree/templates

By default, these are the templates used (same format as old emails):
https://github.com/dani-garcia/bitwarden_rs/tree/templates/src/static/templates
Note that the first part is the subject, the second part is the body, and the separator has to be exactly the same.

You can change them by creating files with the same name in $data_folder/templates, or using the TEMPLATES_FOLDER variable.

I'd welcome anyone to test it or to improve the default templates, which are pretty lackluster.

@dani-garcia commented on GitHub (Jan 13, 2019): I created a new branch with initial support for templates: https://github.com/dani-garcia/bitwarden_rs/tree/templates By default, these are the templates used (same format as old emails): https://github.com/dani-garcia/bitwarden_rs/tree/templates/src/static/templates Note that the first part is the subject, the second part is the body, and the separator has to be exactly the same. You can change them by creating files with the same name in `$data_folder/templates`, or using the `TEMPLATES_FOLDER` variable. I'd welcome anyone to test it or to improve the default templates, which are pretty lackluster.
Author
Owner

@dani-garcia commented on GitHub (Jan 15, 2019):

After some testing, the templates branch seems pretty stable so I merged it into master now.

If anyone wants to design better default templates, they are more than welcome to do a PR.

@dani-garcia commented on GitHub (Jan 15, 2019): After some testing, the templates branch seems pretty stable so I merged it into master now. If anyone wants to design better default templates, they are more than welcome to do a PR.
Author
Owner

@plsnotracking commented on GitHub (Jul 20, 2020):

@dani-garcia @DirtyCajunRice so I tried sending emails today and the subject/body still uses Bitwarden_RS inspite of the following command:

docker run -d --name bitwarden \
-e SMTP_HOST= id.com \
-e SMTP_SUBJECT="Invitation for Password Manager" \
-e SMTP_FROM_NAME="Password Manager" \
-e SMTP_FROM=id@id.com \
-e SMTP_PORT=587 \
-e SMTP_SSL=true \
-e SMTP_USERNAME=id@id.com \
-e SMTP_PASSWORD=password \
-e SIGNUPS_ALLOWED=false \
-e ADMIN_TOKEN=SwigglyStuff \
-e WEBSOCKET_ENABLED=true \
-e DOMAIN=https://bw.domain.com \
-p 80:80 \
-v /bw-data/:/data/ \
-v bitwarden:/config \
--restart always bitwardenrs/server:latest

Am I missing something?

Thank you.

@plsnotracking commented on GitHub (Jul 20, 2020): @dani-garcia @DirtyCajunRice so I tried sending emails today and the subject/body still uses Bitwarden_RS inspite of the following command: ``` docker run -d --name bitwarden \ -e SMTP_HOST= id.com \ -e SMTP_SUBJECT="Invitation for Password Manager" \ -e SMTP_FROM_NAME="Password Manager" \ -e SMTP_FROM=id@id.com \ -e SMTP_PORT=587 \ -e SMTP_SSL=true \ -e SMTP_USERNAME=id@id.com \ -e SMTP_PASSWORD=password \ -e SIGNUPS_ALLOWED=false \ -e ADMIN_TOKEN=SwigglyStuff \ -e WEBSOCKET_ENABLED=true \ -e DOMAIN=https://bw.domain.com \ -p 80:80 \ -v /bw-data/:/data/ \ -v bitwarden:/config \ --restart always bitwardenrs/server:latest ``` Am I missing something? Thank you.
Author
Owner

@dani-garcia commented on GitHub (Jul 21, 2020):

SMTP_SUBJECT is not a valid option, if you want to modify the emails, you need to change the template files directly (basically copy the files from https://github.com/dani-garcia/bitwarden_rs/tree/master/src/static/templates and paste them into a the /bw-data/templates folder, keeping all subdirectories the same)

@dani-garcia commented on GitHub (Jul 21, 2020): SMTP_SUBJECT is not a valid option, if you want to modify the emails, you need to change the template files directly (basically copy the files from https://github.com/dani-garcia/bitwarden_rs/tree/master/src/static/templates and paste them into a the /bw-data/templates folder, keeping all subdirectories the same)
Author
Owner

@plsnotracking commented on GitHub (Jul 22, 2020):

Thank you, will try this. Really appreciate it.

@plsnotracking commented on GitHub (Jul 22, 2020): Thank you, will try this. Really appreciate it.
Author
Owner

@Maz-17 commented on GitHub (Oct 11, 2021):

Running latest Vaultwarden using Docker

Hello? Anybody reading this? I got a question about Email templates... here goes...

I only need to copy over the files that I wish to make changes to right?
If I'm looking to make a change to the header and footer section of all mail sent from my vaultwarden instance, all I would need to do is copy the corresponding .hbs files from the link dani (my king) provided over to my /bw-data/templates/ folder ...where do I go from here once this has been done?

Do I need to add an environmental variable to my docker build for my instance to pick up on the overriding template files in this folder?

Apologies if I've missed a link somewhere explaining this procedure/guide already...

Many thanks,
Maz

@Maz-17 commented on GitHub (Oct 11, 2021): Running latest Vaultwarden using Docker Hello? Anybody reading this? I got a question about Email templates... here goes... I only need to copy over the files that I wish to make changes to right? If I'm looking to make a change to the header and footer section of all mail sent from my vaultwarden instance, all I would need to do is copy the corresponding .hbs files from the link dani (my king) provided over to my /bw-data/templates/ folder ...where do I go from here once this has been done? Do I need to add an environmental variable to my docker build for my instance to pick up on the overriding template files in this folder? Apologies if I've missed a link somewhere explaining this procedure/guide already... Many thanks, Maz
Author
Owner

@Maz-17 commented on GitHub (Oct 12, 2021):

Running latest Vaultwarden using Docker

Hello? Anybody reading this? I got a question about Email templates... here goes...

I only need to copy over the files that I wish to make changes to right? If I'm looking to make a change to the header and footer section of all mail sent from my vaultwarden instance, all I would need to do is copy the corresponding .hbs files from the link dani (my king) provided over to my /bw-data/templates/ folder ...where do I go from here once this has been done?

Do I need to add an environmental variable to my docker build for my instance to pick up on the overriding template files in this folder?

Apologies if I've missed a link somewhere explaining this procedure/guide already...

Many thanks, Maz

Figured it out. Re-read this page again and pieced it together. All I did was create the required folders (in my case; templates/email) in your instance's $DATA folder (bw-data) for me - (bw-data/templates/email) and create or upload the required .hbs files you need to make changes to.

As I'm using Docker, I DID have to restart my docker instance for the changes to take affect. Make sure permissions etc are correct for any new folder/files etc also if you're running your docker instance under a specified user.

@Maz-17 commented on GitHub (Oct 12, 2021): > Running latest Vaultwarden using Docker > > Hello? Anybody reading this? I got a question about Email templates... here goes... > > I only need to copy over the files that I wish to make changes to right? If I'm looking to make a change to the header and footer section of all mail sent from my vaultwarden instance, all I would need to do is copy the corresponding .hbs files from the link dani (my king) provided over to my /bw-data/templates/ folder ...where do I go from here once this has been done? > > Do I need to add an environmental variable to my docker build for my instance to pick up on the overriding template files in this folder? > > Apologies if I've missed a link somewhere explaining this procedure/guide already... > > Many thanks, Maz Figured it out. Re-read this page again and pieced it together. All I did was create the required folders (in my case; templates/email) in your instance's $DATA folder (bw-data) for me - (bw-data/templates/email) and create or upload the required .hbs files you need to make changes to. As I'm using Docker, I DID have to restart my docker instance for the changes to take affect. Make sure permissions etc are correct for any new folder/files etc also if you're running your docker instance under a specified user.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/vaultwarden#178