mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2026-02-25 03:11:09 +03:00
SMTP Templates #178
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.
@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.
@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).
Edit: snmp to smtp. Oof it was late last night!
@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:
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_NAMEwould probably be the same for all emails, so we should definitely add that as an env option next toSMTP_FROM@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
@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 theTEMPLATES_FOLDERvariable.I'd welcome anyone to test it or to improve the default templates, which are pretty lackluster.
@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.
@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:
Am I missing something?
Thank you.
@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)
@plsnotracking commented on GitHub (Jul 22, 2020):
Thank you, will try this. Really appreciate it.
@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 12, 2021):
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.