# Mail container setup This is one of the trickier ones. ## Instructions First, get the email server up and running: ``` ansible-playbook main.yml ``` At this point, it would be a good idea to send a few emails back and forth between the dummy users to make sure everything's working (their usernames are alice, bob, and eve). [Mutt](http://www.mutt.org/) has already been setup for each user. ``` lxc-attach mail su - alice mutt (send an email to bob@csclub.internal) exit su - bob mutt (check that alice's email got sent) ``` ## Installing Mailman 2 ``` ansible-playbook mailman2/mailman2.yml ``` Attach to the mail container and create a new list, e.g. syscom: ``` cd /var/lib/mailman bin/newlist -a syscom root@csclub.internal mailman ``` ### Standalone bridge If you are using a standalone bridge, unfortunately you will not be able to access the container directly from your physical host because it is behind a NAT. I suggest running socat on the VM for TCP forwarding: ``` apt install socat socat TCP-LISTEN:80,fork TCP:192.168.100.52:80 ``` This will forward requests to port 80 on the VM to port 80 in the mail container. Alternatively, you can use iptables: ``` iptables -t nat -A PREROUTING -s 192.168.122.0/24 -p tcp --dport 80 -j DNAT --to-destination 192.168.100.52 ``` Replace '192.168.122.0/24' by the subnet of your VM (your physical host should also be on this subnet), and replace '192.168.100.52' by the IP of the mail container. To make sure this iptables rule is applied automatically at startup, you can install the iptables-persistent package: ``` apt install iptables-persistent ``` You can use `dpkg-reconfigure iptables-persistent` if you ever need to change the iptables rules which are applied at startup. Now open `/etc/hosts` on your computer and add the following entry: ``` 192.168.122.225 mailman.csclub.internal ``` Replace `192.168.122.225` with the default IP of the VM. ### Shared bridge If you are using a shared bridge, you can access the container directly from your physical host. Add the following entry to your `/etc/hosts`: ``` 192.168.100.52 mailman.csclub.internal ``` Replace `192.168.100.52` with the IP of the mail container. ## Mailman web interface Now on your physical host, you are going to visit the web interface for Mailman to adjust some settings and subscribe some new users. Visit http://mailman.csclub.internal/admin/syscom in your browser. The admin password is 'mailman' (no quotes). I suggest going over each setting in the Privacy section and reading it carefully. Under 'Sender filters', I suggest setting 'generic_nonmember_action' to 'Accept' rather than 'Hold'. Under 'Recipient filters', I suggest setting 'require_explicit_destination' to 'No'. If you are feeling adventurous, add the following to the `/etc/aliases` file in the mail container: ``` www-data: root root: syscom ``` Then run `postalias /etc/aliases` and `postfix reload`. This is actually what the CSC uses on the real mail container (on xylitol). Make sure not to create mailing loops, though, especially when you make one mailing list the owner of another mailing list. You should also subscribe some members to the list and make sure that messages get sent to them properly. Go to http://mailman.csclub.internal/listinfo/syscom and subscribe both alice@csclub.internal and bob@csclub.internal. They will get confirmation messages; go back to the mail container and use Mutt as each user to confirm their subscriptions. Then, as either bob or alice, send a message to the syscom list, and make sure that they both received the message. You should also be able to see the message in Pipermail by going to http://mailman.csclub.internal/pipermail/syscom/. ## Installing Mailman 3 Make sure you have installed Mailman 2 first, since we are going to need Pipermail. We are also going to need the MariaDB database on coffee, so make sure the coffee container has been setup. Run the playbook for Mailman 3: ``` ansible-playbook mailman3/mailman3.yml ``` Run the database migration and collect static files: ``` cd /opt/mailman3 su -s /bin/bash www-data source bin/activate mailman-web migrate mailman-web collectstatic mailman-web compress exit systemctl restart mailman3-web ``` You will also want to create a superuser account: ``` cd /opt/mailman3 su -s /bin/bash www-data source bin/activate mailman-web createsuperuser --username bob --email bob@csclub.internal exit ``` Now open http://mailman.csclub.internal in your browser, login as bob, and start doing things. See the official [Mailman 3 documentation](https://docs.mailman3.org) and [our wiki](https://wiki.csclub.uwaterloo.ca/Mailing_Lists#Mailman_3) for information on how to create lists, import lists from Mailman 2, etc. Make sure to send some messages to the lists which you create to verify that everything's working.