Seeking Advice on Mail Delivery Setup for Discourse Multisite

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!

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

2 Likes

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

2 Likes

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:

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!

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.

2 Likes

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

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

and that should be it? THANK YOU!

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

2 Likes