# Seeking Advice on Mail Delivery Setup for Discourse Multisite

**URL:** https://meta.discourse.org/t/seeking-advice-on-mail-delivery-setup-for-discourse-multisite/347227
**Category:** Self-hosting
**Tags:** multisite
**Created:** [January 15, 2025, 9:47am UTC](https://meta.discourse.org/t/seeking-advice-on-mail-delivery-setup-for-discourse-multisite/347227 "2025-01-15T09:47:25Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![onebigunicorn](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/onebigunicorn/32/481011_2.png) [@onebigunicorn](https://meta.discourse.org/u/onebigunicorn)
#### Post date: [January 15, 2025, 9:47am UTC](https://meta.discourse.org/t/seeking-advice-on-mail-delivery-setup-for-discourse-multisite/347227/1 "2025-01-15T09:47:25Z")

</div>

Hi everyone,

After a few weeks of experimenting, I’m thrilled to have successfully deployed a multisite setup within a single container (after many fails). This has been an incredible accomplishment for me, as I’m working with very limited resources (around 1.34GB of memory for two sites is amazing, which is much better than running two separate containers).

I’m setting up communities to try and do a bit of good in this world, but unfortunately, I can’t afford very expensive hosting services— even $20/month is a significant expense for me. I’m determined to make this work with the resources I have, which is why I’m reaching out for guidance.

However, I’ve hit a bit of a snag regarding mail delivery for each subdomain. From what I’ve gathered, it seems that native support for distinct email addresses per site isn’t available in a multisite configuration. This strikes me as odd, especially since Discourse manages hosted instances like `xyz.discourse.group` and I assume you don’t allocate 2GB of memory per instance. Surely, you’re utilizing a similar multisite approach?

My question is: how do you handle email delivery for each subdomain?

For example, if I have sites `xyz1.domain.com` and `xyz2.domain.com`, I want outgoing emails to appear as `notification@xyz1.domain.com` and `notification@xyz2.domain.com` respectively, rather than everything being sent from one generic address. I’ve tried configuring Postfix with header checks (e.g., `X-Originating-Domain`) but hit a wall since all emails originate from the same address. Would leveraging something like the `List-Id` header be a better approach? I understand that this maybe bit of a sensitive topic, maybe proprietary information, but any help is appriciated.

I suspect I might be overthinking this and there’s a simpler solution I’m overlooking. If you could share how you achieve this (or point me in the right direction), I’d be incredibly grateful.

Thank you in advance for your time and any insights you can offer!

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [January 15, 2025, 10:13am UTC](https://meta.discourse.org/t/seeking-advice-on-mail-delivery-setup-for-discourse-multisite/347227/2 "2025-01-15T10:13:40Z")

</div>

> [@onebigunicorn](#):
>
> native support for distinct email addresses per site isn’t available in a multisite configuration

This is incorrect. Where did you get that?  
You can set `notification_email` per instance.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [January 15, 2025, 1:21pm UTC](https://meta.discourse.org/t/seeking-advice-on-mail-delivery-setup-for-discourse-multisite/347227/3 "2025-01-15T13:21:23Z")

</div>

> [@onebigunicorn](#):
>
> it seems that native support for distinct email addresses per site isn’t available

Native support for distinct email _credentials_ per site isn’t available.

---

<div class="post-metadata">

### Author: ![onebigunicorn](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/onebigunicorn/32/481011_2.png) [@onebigunicorn](https://meta.discourse.org/u/onebigunicorn)
#### Post date: [January 15, 2025, 2:26pm UTC](https://meta.discourse.org/t/seeking-advice-on-mail-delivery-setup-for-discourse-multisite/347227/4 "2025-01-15T14:26:36Z")

</div>

Hi again,

Apologies for the confusion in my earlier post—I realize I didn’t describe the issue correctly. Let me clarify.

The challenge I’m facing is with email delivery in a multisite setup where the primary concern isn’t subdomains but entirely different main domains. For example, I’m trying to configure sites like `xyz1.domain1.com` and `xyz2.domain2.com` within the same Discourse container.

I understand that Discourse allows you to define a single notification email in `app.yml`, such as:

```plaintext
DISCOURSE_SMTP_ADDRESS: smtp.domain1.com
DISCOURSE_SMTP_PORT: 587
DISCOURSE_SMTP_USER_NAME: noreply@domain1.com
DISCOURSE_SMTP_PASSWORD: password
DISCOURSE_SMTP_ENABLE_START_TLS: true

```

his works perfectly for the first instance (`xyz1.domain1.com`). However, when emails are sent from the second instance (`xyz2.domain2.com`), email providers like Gmail flag them as mismatched because the email headers don’t align with the `xyz2.domain2.com` domain. Essentially, I can’t define separate SMTP configurations for each domain in a single multisite setup.

Has anyone successfully handled this scenario where each main domain in a multisite setup uses its own distinct SMTP credentials (e.g., separate `DISCOURSE_SMTP_*` settings per site)? Is there a workaround, or does this require separate containers for each domain to avoid mismatches?

Alternatively, are there any best practices or tools (e.g., Postfix tweaks, using List-Id headers) that could help resolve the mismatch issue without needing separate containers for each site?

I’d greatly appreciate any insights or suggestions. Thanks again for your time and support!

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [January 15, 2025, 2:36pm UTC](https://meta.discourse.org/t/seeking-advice-on-mail-delivery-setup-for-discourse-multisite/347227/5 "2025-01-15T14:36:36Z")

</div>

> [@onebigunicorn](#):
>
> However, when emails are sent from the second instance (`xyz2.domain2.com`), email providers like Gmail flag them as mismatched because the email headers don’t align with the `xyz2.domain2.com` domain

Even though this looks like a limitation of Discourse because a multisite setup only allows you to use a single account for sending, this is in fact a limitation of your email provider where they only allow you to use a single From address under your account.

The fact that the `SMTP_USER_NAME` looks like an email address is because they have _chosen to enforce_ that the `From:` header of the mails you send have to be the same (or: are rewritten to be the same) as the `SMTP_USER_NAME`.

The email headers are being set by Discourse and if you use an email provider that doesn’t touch them and allows you to use multiple from addresses under the same account, everything will work fine.

---

<div class="post-metadata">

### Author: ![onebigunicorn](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/onebigunicorn/32/481011_2.png) [@onebigunicorn](https://meta.discourse.org/u/onebigunicorn)
#### Post date: [January 15, 2025, 3:16pm UTC](https://meta.discourse.org/t/seeking-advice-on-mail-delivery-setup-for-discourse-multisite/347227/6 "2025-01-15T15:16:05Z")

</div>

I see so I basically need to configure Postfix to create custom header checks:

```plaintext
/^From:.+@example\.com/ REPLACE From: Your Name <yourname@example.com>

```

and that should be it? THANK YOU!

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [January 15, 2025, 7:23pm UTC](https://meta.discourse.org/t/seeking-advice-on-mail-delivery-setup-for-discourse-multisite/347227/7 "2025-01-15T19:23:30Z")

</div>

If you are using your own Postfix install then I don’t see why this would be a problem at all.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [February 14, 2025, 7:24pm UTC](https://meta.discourse.org/t/seeking-advice-on-mail-delivery-setup-for-discourse-multisite/347227/8 "2025-02-14T19:24:26Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
