Closed ggilestro closed 5 months ago
I am currently running this on multiple domains but it requires some manual changes to configuration files which are obviously a bit annoying because they do not survive the respawn of a container via docker or docker compose. The changes needed are the following:
- Add a line for each extra domain to
mm_cfg.py
in the following way:add_virtualhost(DEFAULT_URL_HOST, DEFAULT_EMAIL_HOST) add_virtualhost('lists.additional_domain_1.org', 'additional_domain_1.org') add_virtualhost('lists.additional_domain_2.org', 'additional_domain_2.org')
- add all the relevant hostnames to
/etc/exim4/update-exim4.conf.conf
# this is necessary otherwise exim will throw error 550 and reject relay dc_other_hostnames=primary_domain.org:additional_domain_1.org:additional_domain_2.org
and to
/etc/exim4/conf.d/main/04_mailman_options
domainlist mm_domains=primary_domain.org:additional_domain_1.org:additional_domain_2.org
With these changes mailman can handle multiple lists just fine. It would be nice if we could please integrate this with the current
RUN.sh
script. Probably the easiest would be to introduce two new ENV variables: URL_VIRTUAL_HOSTS and EMAIL_VIRTUAL_HOSTSThen in RUN.sh something like that:
# Convert comma-separated lists into arrays IFS=',' read -r -a url_hosts_array <<< "$URL_VIRTUAL_HOSTS" IFS=',' read -r -a email_hosts_array <<< "$EMAIL_VIRTUAL_HOSTS" # Check if the arrays have the same length if [ ${#url_hosts_array[@]} -ne ${#email_hosts_array[@]} ]; then echo "The lists have different lengths." exit 1 fi # Add virtual hosts to /etc/mailman/mm_cfg.py for ((i = 0; i < ${#url_hosts_array[@]}; ++i)); do echo "add_virtualhost('${url_hosts_array[$i]}', '${email_hosts_array[$i]}')" >> $mailmancfg done # Construct the domain list for Exim configuration domain_list="$PRIMARY_DOMAIN" for email_host in "${email_hosts_array[@]}"; do domain_list+=":$email_host" done # Update /etc/exim4/update-exim4.conf.conf - not quite compatible with the current strategy based on sed echo "dc_other_hostnames='$domain_list'" >> /etc/exim4/update-exim4.conf.conf # Update /etc/exim4/conf.d/main/04_mailman_options echo "domainlist mm_domains='$domain_list'" >> /etc/exim4/conf.d/main/04_mailman_options echo "Configuration updated successfully."
Thanks!! You saved my life!!
Sorry for the long delay, I've finally found time to have a look at your request and have considered the implications of the suggested environment variables and script changes for supporting multiple domains in the d3fk/mailman2
container image.
I assume you have considered the possibility of deploying several containers on the same server for your use case. This approach, while feasible, introduces the inconvenience of managing a distinct web interface for each domain and requires additional configurations, such as setting up a load balancer, reverse proxy, or ingress to correctly redirect the requests to the appropriate container based on the domain name.
While your modifications are indeed valuable for a specific use case, I've decided not to integrate them into the main repository. The goal of this container is to provide a quick and straightforward setup. Introducing additional environment variables for multi-domain support could complicate the configuration process, which we aim to keep as simple as possible for the majority of users.
Given your specific needs, I recommend creating a custom Docker image based on the d3fk/mailman2
image. This way, you can include your configurations directly in the image rather than relying on manual changes to configuration for each deployment. Here’s a simple example of how to set up your Dockerfile:
FROM d3fk/mailman2
COPY {LOCAL_PATH}/mm_cfg.py /etc/mailman/mm_cfg.py
RUN echo "dc_other_hostnames=primary_domain.org:additional_domain_1.org:additional_domain_2.org" >> /etc/exim4/update-exim4.conf.conf \
&& echo "domainlist mm_domains=primary_domain.org:additional_domain_1.org:additional_domain_2.org" >> /etc/exim4/conf.d/main/04_mailman_options
You can then build and run your customized container with the following basic commands, modifying them as necessary:
docker build -t yourcustommailman .
docker run yourcustomailman
This approach ensures that your modifications are preserved across container restarts and deployments, maintaining consistency through different versions, without altering the core simplicity of the original container setup.
Hope this helps!
I am currently running this on multiple domains but it requires some manual changes to configuration files which are obviously a bit annoying because they do not survive the respawn of a container via docker or docker compose. The changes needed are the following:
Add a line for each extra domain to
mm_cfg.py
in the following way:add all the relevant hostnames to
/etc/exim4/update-exim4.conf.conf
and to
/etc/exim4/conf.d/main/04_mailman_options
With these changes mailman can handle multiple lists just fine. It would be nice if we could please integrate this with the current
RUN.sh
script. Probably the easiest would be to introduce two new ENV variables: URL_VIRTUAL_HOSTS and EMAIL_VIRTUAL_HOSTSThen in RUN.sh something like that: