[PR #5995] [CLOSED] Add separate mailing domain support #20531

Closed
opened 2026-04-25 22:35:00 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/dani-garcia/vaultwarden/pull/5995
Author: @mohammadmaso
Created: 6/28/2025
Status: Closed

Base: mainHead: mailing_domain


📝 Commits (4)

  • 98d12fe refactor email URL generation to use effective mailing domain
  • e35de74 add mailing_domain configuration option and effective_mailing_domain method
  • 74912a0 add mailing domain configuration documentation
  • 5502114 Merge branch 'main' into mailing_domain

📊 Changes

3 files changed (+89 additions, -27 deletions)

View changed files

MAILING_DOMAIN.md (+54 -0)
📝 src/config.rs (+8 -0)
📝 src/mail.rs (+27 -27)

📄 Description

Mailing Domain Configuration

This feature allows you to configure a separate domain specifically for email templates and links, while keeping your main DOMAIN setting for internal server access.

Configuration

Environment Variable

Set the MAILING_DOMAIN environment variable:

MAILING_DOMAIN=https://public.example.com

Docker Environment

Add to your docker-compose.yml or docker run command:

environment:
  - MAILING_DOMAIN=https://public.example.com

Or with docker run:

docker run -e MAILING_DOMAIN=https://public.example.com vaultwarden/server

Admin Panel

The mailing domain can also be configured through the admin panel under SMTP Email Settings.

Use Cases

  1. Internal vs Public Access: Your Vaultwarden server runs on an internal domain (e.g., http://vaultwarden.internal) but you want emails to contain links to a public domain (e.g., https://vault.company.com).

  2. Development vs Production: Use different domains for email links in development and production environments.

  3. Load Balancer/Proxy: Your server runs behind a load balancer with a different internal address than the public-facing URL.

Behavior

  • If MAILING_DOMAIN is set, all email templates will use this domain for links and references
  • If MAILING_DOMAIN is not set, the system falls back to using the main DOMAIN setting
  • This affects all email types: invitations, password resets, 2FA emails, notifications, etc.

Example

# Main domain for server operations
DOMAIN=http://vaultwarden.internal:8080

# Public domain for email links
MAILING_DOMAIN=https://vault.company.com

With this configuration:

  • The server operates on http://vaultwarden.internal:8080
  • All email links will point to https://vault.company.com

🔄 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/5995 **Author:** [@mohammadmaso](https://github.com/mohammadmaso) **Created:** 6/28/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `mailing_domain` --- ### 📝 Commits (4) - [`98d12fe`](https://github.com/dani-garcia/vaultwarden/commit/98d12fe143a3f1c8cb033944974da38dbb44ebda) refactor email URL generation to use effective mailing domain - [`e35de74`](https://github.com/dani-garcia/vaultwarden/commit/e35de74d8b2a5d39f2a445116a04aaec82c51235) add mailing_domain configuration option and effective_mailing_domain method - [`74912a0`](https://github.com/dani-garcia/vaultwarden/commit/74912a04f0cedbe16a63d758ccab6c06f818b481) add mailing domain configuration documentation - [`5502114`](https://github.com/dani-garcia/vaultwarden/commit/5502114db33fc31ec3279f9ea4942921e6b370bc) Merge branch 'main' into mailing_domain ### 📊 Changes **3 files changed** (+89 additions, -27 deletions) <details> <summary>View changed files</summary> ➕ `MAILING_DOMAIN.md` (+54 -0) 📝 `src/config.rs` (+8 -0) 📝 `src/mail.rs` (+27 -27) </details> ### 📄 Description # Mailing Domain Configuration This feature allows you to configure a separate domain specifically for email templates and links, while keeping your main `DOMAIN` setting for internal server access. ## Configuration ### Environment Variable Set the `MAILING_DOMAIN` environment variable: ```bash MAILING_DOMAIN=https://public.example.com ``` ### Docker Environment Add to your docker-compose.yml or docker run command: ```yaml environment: - MAILING_DOMAIN=https://public.example.com ``` Or with docker run: ```bash docker run -e MAILING_DOMAIN=https://public.example.com vaultwarden/server ``` ### Admin Panel The mailing domain can also be configured through the admin panel under SMTP Email Settings. ## Use Cases 1. **Internal vs Public Access**: Your Vaultwarden server runs on an internal domain (e.g., `http://vaultwarden.internal`) but you want emails to contain links to a public domain (e.g., `https://vault.company.com`). 2. **Development vs Production**: Use different domains for email links in development and production environments. 3. **Load Balancer/Proxy**: Your server runs behind a load balancer with a different internal address than the public-facing URL. ## Behavior - If `MAILING_DOMAIN` is set, all email templates will use this domain for links and references - If `MAILING_DOMAIN` is not set, the system falls back to using the main `DOMAIN` setting - This affects all email types: invitations, password resets, 2FA emails, notifications, etc. ## Example ```bash # Main domain for server operations DOMAIN=http://vaultwarden.internal:8080 # Public domain for email links MAILING_DOMAIN=https://vault.company.com ``` With this configuration: - The server operates on `http://vaultwarden.internal:8080` - All email links will point to `https://vault.company.com` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-25 22:35:00 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/vaultwarden#20531