[PR #3147] [MERGED] add support for system mta though sendmail #3232

Closed
opened 2026-03-03 09:42:00 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/dani-garcia/vaultwarden/pull/3147
Author: @soruh
Created: 1/16/2023
Status: Merged
Merged: 2/12/2023
Merged by: @dani-garcia

Base: mainHead: main


📝 Commits (4)

  • b7c4316 Add support for sendmail as a mail transport
  • 8cc6dac check if SENDMAIL_COMMAND is valid using 'which' crate
  • 9e3d7ea add EXE_SUFFIX to sendmail executable when not specified
  • f92efda Merge branch 'main' into main

📊 Changes

5 files changed (+135 additions, -46 deletions)

View changed files

📝 .env.template (+6 -1)
📝 Cargo.lock (+12 -0)
📝 Cargo.toml (+2 -1)
📝 src/config.rs (+52 -12)
📝 src/mail.rs (+63 -32)

📄 Description

This PR enables using lettre's SendmailTransport in Vaultwarden.

It adds two configuration options:
- USE_SENDMAIL wether to use sendmail instead of directly connecting to a SMTP server
- SENDMAIL_COMMAND what sendmail command to use. By default the one from the $PATH is used, but I think there are cases where it makes sense to specify a different one

Supporting the system MTA allows for more flexible mail configuration without too much effort and does not require packaging any sendmail client as assumed in #2198.

While there are other usecases like sending through a local mailserver without having to create a dedicated SMTP Account as mentioned in #2198, my specific usecase for this is the following:

I have msmtp configured with an account that all applications use without me having to paste the SMTP configuration and credentials into each of their configs and allows me to only have to maintain the one SMTP configuration instead of potentially forgetting one (not fun).

Testing can be done as follows:

> sudo pacman -S msmtp-mta
> sudo tee /etc/msmtprc << EOF
defaults

account default
auth on
from <from>
host <hostname>
password <passowrd>
tls on
user <username>
EOF
> tee .env << EOF
USE_SENDMAIL = true
SMTP_FROM = "bitwarden@tld"
EOF
> cargo run [...] # run vaultwarden

log into vaultwarden, click
User icon in top right > account settings > security > Two-step login > Email > Manage > Send Email


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/dani-garcia/vaultwarden/pull/3147 **Author:** [@soruh](https://github.com/soruh) **Created:** 1/16/2023 **Status:** ✅ Merged **Merged:** 2/12/2023 **Merged by:** [@dani-garcia](https://github.com/dani-garcia) **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (4) - [`b7c4316`](https://github.com/dani-garcia/vaultwarden/commit/b7c4316c778568d23cdd7e3922e03cf16a3fec18) Add support for sendmail as a mail transport - [`8cc6dac`](https://github.com/dani-garcia/vaultwarden/commit/8cc6dac893e3a7630a6be438ac4331f0f7023dad) check if SENDMAIL_COMMAND is valid using 'which' crate - [`9e3d7ea`](https://github.com/dani-garcia/vaultwarden/commit/9e3d7ea44c2813ffaddb0accd768407ad1664a55) add EXE_SUFFIX to sendmail executable when not specified - [`f92efda`](https://github.com/dani-garcia/vaultwarden/commit/f92efda0f0568a3fdf248b2da998a9f8925139c6) Merge branch 'main' into main ### 📊 Changes **5 files changed** (+135 additions, -46 deletions) <details> <summary>View changed files</summary> 📝 `.env.template` (+6 -1) 📝 `Cargo.lock` (+12 -0) 📝 `Cargo.toml` (+2 -1) 📝 `src/config.rs` (+52 -12) 📝 `src/mail.rs` (+63 -32) </details> ### 📄 Description This PR enables using `lettre`'s `SendmailTransport` in Vaultwarden. It adds two configuration options: - `USE_SENDMAIL` wether to use sendmail instead of directly connecting to a SMTP server - `SENDMAIL_COMMAND` what sendmail command to use. By default the one from the `$PATH` is used, but I think there are cases where it makes sense to specify a different one Supporting the system MTA allows for more flexible mail configuration without too much effort and does not require packaging any sendmail client as assumed in #2198. While there are other usecases like sending through a local mailserver without having to create a dedicated SMTP Account as mentioned in #2198, my specific usecase for this is the following: I have msmtp configured with an account that all applications use without me having to paste the SMTP configuration and credentials into each of their configs and allows me to only have to maintain the one SMTP configuration instead of potentially forgetting one (not fun). Testing can be done as follows: ```bash > sudo pacman -S msmtp-mta > sudo tee /etc/msmtprc << EOF defaults account default auth on from <from> host <hostname> password <passowrd> tls on user <username> EOF > tee .env << EOF USE_SENDMAIL = true SMTP_FROM = "bitwarden@tld" EOF > cargo run [...] # run vaultwarden ``` log into vaultwarden, click User icon in top right > account settings > security > Two-step login > Email > Manage > Send Email --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-03 09:42:00 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vaultwarden#3232
No description provided.