Can a single Mail Receiver handle emails for all sites in a Discourse multisite setup?

AI-generated summary

In a Discourse multisite setup, configuring a single Mail Receiver to handle emails for all forums is not straightforward. Abdelrahman_MoHamed initially asked if one Mail Receiver could route emails by domain, and thoka suggested adapting the receiver’s code, even proposing using the same API key across sites as a workaround [4]. However, denvergeeks confirmed a working solution: deploying a separate Mail Receiver container per forum, each mapped via Postfix transport maps to its respective domain. Abdelrahman_MoHamed asked clarifying questions about Postfix setup, volume mounts, and domain blocking, to which denvergeeks and [10] confirmed the need for unique volume paths per forum (e.g., /var/discourse/shared/mail-receiver-N/postfix-spool) to isolate spools and enable domain blocking features. After implementation, Abdelrahman_MoHamed reported success and thanked the community, asking about security best practices. denvergeeks acknowledged the lack of known security enhancements but praised the collaborative spirit and encouraged further community input. The thread concludes with mutual appreciation and validation of the multi-container approach as the current best practice for multisite email routing.

We are currently running Discourse with a multisite setup, and we plan to use the Mail Receiver for email handling. I have a question about the configuration:

Is it possible to configure a single Mail Receiver container to handle incoming emails for all forums in the multisite setup?

I want to ensure that the incoming emails are correctly routed to the appropriate forum based on their domain. Has anyone configured Mail Receiver in a similar setup?

Any guidance, examples, or best practices would be greatly appreciated!

It might be sufficient to adapt this function for multisite:

Thanks for sharing this , but what about the API key how will the mail receiver handle this ?

A hacky way would be to use the same API key on every instance.

Sounds crazy but I can give it a try!

I just did something similar which is working

Thank you so much @denvergeeks for sharing this with me but I have some questions:-

  1. Have you installed Postfix on your server first?
  2. According to your docs I will need to create a mail receiver container for each forum right?
  3. You map the domain to its corresponding forum using the transport map.
  4. I see that you have made some changes to the volume mounts too.

Yes, all correct.

Thanks for the confirmation, but can you explain why did you add additional volume because I see both are even different from the default one

It is because of this section… to make available the functionality for blocking certain domains.

Greate, one last question .

Should I create a new path for each mail receiver for example I have about 10 forums so I will need to create new volume for each one od them like this

Default forum:

- volumes:
      host: /var/discourse/shared/mail-receiver/postfix-spool
      guest: /var/spool/postfix

First forum:

- volumes:
      host: /var/discourse/shared/mail-receiver-1/postfix-spool
      guest: /var/spool/postfix

Second forum:

- volumes:
      host: /var/discourse/shared/mail-receiver2/postfix-spool
      guest: /var/spool/postfix

Yes that is correct :+1:

Really appreciated, I will start the implementation and keep you updated

Hi @denvergeeks

Thanks to your support, I’ve gained a much clearer understanding of how to proceed. I admire the way you generously share your knowledge, and I’m grateful to be part of such a collaborative community it’s working now.

I do have a quick follow-up question: Is there any additional configuration or best practices you’d recommend for enhancing security in this setup?

Thanks again for your support—it means a lot to me!

Looking forward to hearing from you.

Not that I know of but, I agree with you, that is the next question for which I hope we’ll get some guidance from the community!

Great work! I really appreciate your postings about your progress and results as well - it is a really nice validation and reward for my efforts in sharing!