Giter VIP home page Giter VIP logo

Comments (2)

agutf avatar agutf commented on July 19, 2024

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:

  1. 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')
  1. 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_HOSTS

Then 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!!

from mailman2.

Angatar avatar Angatar commented on July 19, 2024

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!

from mailman2.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.