Skip to content

DevNotes_Processeses_MailmanConfig

Paul Butler edited this page Nov 14, 2024 · 9 revisions

Adding a new list to sasview.org on the UTK DANSE server

  • create the list from the web interface
  • go through and setup settings

Both Postfix and MAILMAN Now Need Some Files Adjusted

POSTFIX

  • Using an editor (e.g. nano) add the following line to /etc/postfix/virtual (sudo priviledges needed)
  • Next apply the mapping using
sudo postmap /etc/postfix/virtual
  • Finally restart postfix
sudo service postfix restart
sudo service postfix status (to make sure it is now running)

NOW THE MAILMAN SIDE

run the script in /etc/mailmen as

cd /etc/mailmen
sudo ./create_new_list.sh  (runs the script that does all the work for you)
cat mapped-aliases (verify that the new lists appear in the file as expected)

From the last command above verify that the lists have been properly added to the file.

Finally restart the lists using

sudo /etc/init.d/mailmen-lists-sasview-org restart

NOTE ... it is possible that restarting the whole mailman service would also work but not tested. to do so

sudo service mailman restart

Finally, if the archives are to be public see notes on permission setting in item 8 of the next section (under Mailman). They should be correct now but worth checking in case.

Setting up Postfix and Mailman on UTK server from "scratch"

NOTE: these are for Mailman 2. We are hoping to migrate to Mailman 3 soon at which point this page should be moved to the obsolete pages area.

Postfix

  • Some grimness here

In order to allow mail forwarding, SRS is required to rewrite the headers properly when the receiving mail server is doing SPF checks. Useful links:

Install PostSRSd ( ​https://github.com/roehling/postsrsd ) from GitHub? (instructions from ​https://www.mind-it.info/2014/02/22/forward-postfix-spf-srs/ )

# download and compile the software:

$ cd ~
$ wget https://github.com/roehling/postsrsd/archive/master.zip
$ unzip master
$ cd postsrsd-master/
$ sudo make
$ sudo make install

# Add postfix configuration parameters for postsrsd

$ sudo postconf -e "sender_canonical_maps = tcp:127.0.0.1:10001"
$ sudo postconf -e "sender_canonical_classes = envelope_sender"
$ sudo postconf -e "recipient_canonical_maps = tcp:127.0.0.1:10002"
$ sudo postconf -e "recipient_canonical_classes = envelope_recipient"

# Start SRS daemon:

$ sudo service postsrsd start

#Reload postfix:

$ sudo service postfix reload

Mailman

Note: changes made to step 8 by PDB on May 27, 2021 based on experience with public archives being inaccessible following the instructions in step 8. Relevant Mailman documentation can be found at http://www.list.org/mailman-install/node9.html and the problem is discussed in the following listserve thread https://mail.python.org/pipermail/mailman-users/2012-May/073387.html

The default mailman does not properly support multiple domains. On the UTK server we need to have separate instances of mailman for each domain so as to have different admins and main lists etc.

Installed multiple copies of mailman using the script and instructions from ​https://github.com/dpocock/mailmen - a tarball of the code is attached to this page for posterity, and the instructions are as follows (copied from an old page and modified based on experience):

The aim of this script is to rapidly deploy multiple copies
of Mailman on a single host for virtual hosting.

Mailman's design has very limited support for virtual hosting.
Various techniques exist using a shared installation of Mailman.
They have some particular limitations:
 * all virtual lists appear on a single web page
 * each list name must be globally unique across all domains
 * a single shared domain for the "site list"

The only effective way to purely achieve virtual hosting appears to
be installing multiple copies of Mailman, built from source, each
having its own directory tree.  Each tree serves a single domain.

This does not require multiple mail server instances.  A single
mail server instance can be used, however, it is necessary to use
a hack to map virtual aliases to unique names in the aliases file.
The enclosed script "gen-mapped-aliases" automates this.

== Setup procedure ==

1. Install the basic Mailman 2.1.15 Debian package (to provide images and
   other shared artifacts under /usr/share)

2. Set up a directory for the aliases files:

      mkdir /etc/mailmen

   and add them to /etc/postfix/main.cf (do not use line breaks):

      alias_maps = hash:/etc/aliases,
                            hash:/etc/mailmen/mapped-aliases
      virtual_alias_maps = hash:/etc/postfix/virtual,
                            hash:/etc/mailmen/mapped-virtual

3. Get the sources

      apt-get source mailman

   or just download from the Mailman web site. If you are using
   apt-get you may need to execute 'apt-get install dpkg-dev' before
   the source download will work.

4. Build a custom instance for each domain, e.g.:

      fakeroot ./make-mailman mailman_2.1.15.orig.tar.gz lists.example.org

   If you are not on Debian, you may need to tweak "make-mailman", particularly
   the environment variables at the beginning. If you get an error
   message about Python Distutils, execute 'apt-get install python-dev
   python-setuptools'

   You will find tarballs under /tmp for each of your domains, e.g.
   /tmp/mailman-lists.example.org.tar.gz

5. As root, unpack the compiled tarball

      su -
      cd /
      tar xzf /tmp/mailman-lists.example.org.tar.gz

6. Enable the service for each domain:

      update-rc.d mailmen-lists-example-org defaults

7. Create the site list for each domain:

      /var/lib/mailmen/lists.example.org/bin/newlist mailman

   Ignore the instructions about modifying your aliases file, it is done
   later.

8. Fix permissions (or archives won't work) - must be done after creating
   any list! Note that assuming the private directory gives zero permissions
   to "other", any public archive will render with "no permission to access"
   unless the web server is made owner. Thus while the default suggestion
   is to make list owner as follows:

      chown -R list /var/lib/mailmen/lists.example.org/archives/private/*

   The correct approach for the SasView lists (and should always work anyway) would be:

      chown -R www-data:list /var/lib/mailmen/lists.example.org/archives/private/*

   or to do all lists at once:

      chown -R www-data:list /var/lib/mailmen/*/archives/*

9. Update the aliases file for the mailer

      Run the enclosed gen-mapped-aliases script

   Manually check the results in /etc/mailmen

   NOTE: this script must be run every time a new list is created
         with newlist or through the web.  Consider running
         it from cron.

10. Reload the mailer after adding any new virtual domain:

      service postfix reload

11. Add Mailman config to the Apache virtual host, note that you must
    use the cgi-bin path corresponding to the virtual host.

    See the files apache2.conf and apache2-vhost.conf for
    specific examples that are ready to use.

12. Start the service
 
     sudo /etc/init.d/mailmen-lists-example-org start

Config for webserver

<VirtualHost *:80>
  DocumentRoot /var/www/lists.sasview.org
  ServerName lists.sasview.org
  CustomLog /var/log/apache2/lists.sasview.org-access.log combined
  ErrorLog /var/log/apache2/lists.sasview.org-error.log

  RedirectMatch 302 ^/$ http://lists.sasview.org/mailman/listinfo

  ScriptAlias /cgi-bin/mailman/ /var/lib/mailmen/lists.sasview.org/cgi-bin/
  ScriptAlias /mailman/ /var/lib/mailmen/lists.sasview.org/cgi-bin/
  Alias /pipermail/ /var/lib/mailmen/lists.sasview.org/archives/public/
  # use the images from the standard Debian package:
  Alias /images/mailman/ /usr/share/images/mailman/
  Alias /icons/ /usr/share/images/mailman/

  <Directory /var/lib/mailmen/lists.sasview.org/cgi-bin/ >
    AllowOverride None
    Options +ExecCGI
    AddHandler cgi-script .cgi
    Require all granted
</Directory>
<Directory /var/lib/mailmen/lists.sasview.org/archives/public/>
    Options FollowSymlinks
    AllowOverride None
    Require all granted
</Directory>
<Directory /usr/share/images/mailman/>
    AllowOverride None
    Require all granted
</Directory>

</VirtualHost>

VERY IMPORTANT : Set a mailmain site password

sudo /var/lib/<listdomain>/bin/mmsitepass <password>
/etc/init.d/mailman-<listdomain> restart
Clone this wiki locally