Postfix + Mailing List + Mailman

0 views
Skip to first unread message

Janet Denzel

unread,
May 29, 2024, 8:11:13 AM5/29/24
to tuibunwillwin

I have a handful of system users having each one a company email address, handled by postfix.Every week, we send a status email to keep everyone up to date with current developments.Until now, this was only a few people, so it was ok to write their addresses as cc.

Postfix + mailing list + mailman


DOWNLOADhttps://t.co/2M7sHP3yOW



Maybe worth noting, users usual mail addresses are already aliases, so that everyone can use his first name in mail address while still preventing bruteforces to be too easy, so my alias table looks something like that :

When it comes to simple solutions, at literally all places I worked at, the mailing lists (to be more exact; this is a distribution list) were implemented exactly the way you did; so that a sender received a copy of his own mail.

This is not bad, quite the contrary, as with modern MUA's this enables them to display a threaded view in case of a discussion (granted, this shouldn't be too frequent on distribution lists, but happens still and is of some use). And frankly, people are used to it. Some even go as far as automatically CC each mail they send (it might sound crazy to others, but some people function differently and use their inbox for all kinds of stuff..ask the GMail guys).

There is several well known mailling list programs available. Those include Mailman, Majordomo, and Sympa. Mailman is generally regarded as the most mature and feature rich option, and integrates well with most mail servers, including Postfix (RimuHosting recommended).

Its easy to install the basic package, but there can be a few manual steps to get up and running, since the default debian install does not include some basic tweaks. Additionally a lot of documentation is a bit old now which we hope to address here. (Comands below are meant to be run in the server command shell, usually over ssh)

Follow the directions on screen to set the language. Complete the installation by creating the 'mailman' default mailing list and setting up the aliases for that, then finally start the Mailman service.

To test if that looks right use crontab -u list -l. If you need to make changes edit the file in /var/lib/mailman/cron/crontab.in and rerun the command in the previous paragraph. Depending on your needs you will likely want to disable the 'gateway' job.

Then under a standard apache install you will see mailman at -bin/mailman/listinfo/mailman. There are a number of tweaks and tips in the above copied file which I recommend reading to make things integrate a bit more cleanly with your services.

Or Plesk install typically has Mailman installed an enabled by default. Much of the discussion above talks about manually managing the service, if you are using Plesk we recommend managing Mailman from the control panel instead to avoid conflicts with the control panel.

Mailman list messages not going through? Check that the Mailman service is running /etc/init.d/mailman restart. And if not start it and make it run on boot up (on Centos or Fedora run chkconfig --level 3 mailman on, under Debian or Ubuntu run update-rc.d mailman defaults).

You can see the mail queues at something like /var/mailman/qfiles or /var/lib/mailman/qfiles. If the queue is still not being cleared out then delete old lockfiles. e.g. locks/master-qrunner.domain.pid

Mailman needs to communicate with your MTA (mail transport agentor mail server, the software which handles sending mail across theInternet), both to accept incoming mail and to deliver outgoing mail.Mailman itself never delivers messages to the end user. It sends themto its immediate upstream MTA, which delivers them. In the same way,Mailman never receives mail directly. Mail from outside always comesvia the MTA.

Cooperation between Mailman and the MTA requires some configuration ofboth. MTA configuration differs for each of the available MTAs, andthere is a section for each one. Instructions for Postfix and Exim (v4)are given below. We would really appreciate a contribution of aconfiguration for Sendmail, and welcome information about other popularopen source mail servers.

Note that the modules that configure the communication protocol (especiallyincoming) are full-fledged Python modules, and may use these configurationparameters to automatically configure the MTA to recognize the list addressesand other attributes of the communication channel. This is why someconstraints on the format of attributes arise (e.g., lmtp_host), eventhough Mailman itself has no problem with them.

The incoming and outgoing parameters identify the Python objects usedto communicate with the MTA. The python: scheme indicates that the pathsshould be a dotted Python module specification. The deliver module usedin outgoing should be satisfactory for most MTAs. The postfix modulein incoming is specific to the Postfix MTA. See the section for your MTAbelow for details on these parameters.

smtp_host and smtp_port are parameters used to identify the MTA toMailman. If the MTA and Mailman are on separate hosts, smtp_host shouldbe set to the domain name or IP address of the MTA host. smtp_port willalmost always be 25, which is the standard port for SMTP. (Some special siteconfigurations set it to a different port. If you need this, you probablyalready know that, know why, and what to do, too!)

Note that in the above and also below, if your current main.cf containssettings for these items, including the default setting forlocal_recipient_maps, you should add the Mailman setting to the existingsetting rather than replacing it. For example:

Setting local_recipient_maps as well as transport_mapsallows Postfix to properly reject all messages destined for non-existent localusers. Setting relay_domains means Postfix will start to accept mail fornewly added domains even if they are not part of mydestination.

See remarks above about lmtp_host and smtp_host.Also you will have to create another configuration file called aspostfix-mailman.cfg and add its path to the configuration parameterabove. The postfix-mailman.cfg would look like this:

In some cases there will be an existing Postfix configuration in which thedomain that will be used for Mailman 3 lists is a virtual alias domain andfor various reasons, perhaps because it supports Mailman 2 lists and Mailman 3lists need to use the same domain, it must remain a virtual alias domain.This is a challenge because virtual alias domains do not usetransport_maps. This section also applies if the domain is a virtualmailbox domain.

In order to enable this configuration, Mailman domains have analias_domain attribute. This is normally None but can be set to anyotherwise unused domain name. The alias_domain is a fictitious domain thatis not exposed in DNS and is only known to Postfix via the Mailmangenerated mappings. For example if the actual domain is example.com thealias_domain could be x.example.com or even literally bogus.domain.If you set an alias_domain and the configured MTA is Postfix, Mailman will create anadditional /path-to-mailman/var/data/postfix_vmap file with mappings fromthe example.com addresses to the corresponding addresses in thealias_domain and will use the alias_domain in the other files.To use this feature, add the following in main.cf:

For more information regarding how to configure Postfix, please seeThe official Postfix documentation,The reference page for all Postfix configuration parameters,and the documentation for the relay_domains, mydestination andvirtual alias domain settings.

The configuration presented below is mostly boilerplate that allows Exim toautomatically discover your list addresses, and route both posts andadministrative messages to the right Mailman services. For this reason, themailman.mta.exim4 module ends up with all methods being no-ops.

There is copious documentation for Exim. The parts most relevant toconfiguring communication with Mailman 3 are the chapters on the acceptrouter and the LMTP transport. Unless you are already familiarwith Exim configuration, you probably want to start with the chapter onhow Exim receives and delivers mail.

As qmail puts every namespace in the address, we have to filter it out again.If your main domain is example.com and you assign lists.example.com tothe user mailman, qmail will give you the destination addressma...@lists.example.com while it should actually bes...@lists.example.com. The second argument to qmail-lmtp defineshow many parts (separated by dashes) to filter out. The first argumentspecifies the LMTP port of Mailman. An optional third argument specifies theLMTP hostname to connect to (by default localhost).Long story short, as user mailman:

The core Mailman developers generally do not use Sendmail, so experience islimited. Any and all contributions are welcome! There is one suchcontribution on GitHub and another in comments at this issue.

You can integrate Postfix and Mailman such that when new lists are created, orlists are removed, Postfix's alias database will be automatically updated.The following are the steps you need to take to make this work.In the description below, we assume that you've installed Mailman in thedefault location, i.e. /usr/local/mailman. If that's not the case,adjust the instructions according to your use of configure's--prefix and --with-var-prefix options.Note:If you are using virtual domains and you want Mailman to honor your virtualdomains, read the 6.1 section below first! Then come backhere and do these steps.

  • Add this to the bottom of the $prefix/Mailman/mm_cfg.py file: MTA = 'Postfix'The MTA variable names a module in the Mailman/MTA directory which contains the mail server-specific functions to be executed when a list is created or removed.
  • Look at the Defaults.py file for the variables POSTFIX_ALIAS_CMD and POSTFIX_MAP_CMD command. Make sure these point to your postalias and postmap programs respectively. Remember that if you need to make changes, do it in mm_cfg.py.
  • Run the bin/genaliases script to initialize your aliases file. % cd /usr/local/mailman % bin/genaliasesMake sure that the owner of the data/aliases and data/aliases.db file is mailman, that the group owner for those files is mailman, or whatever user and group you used in the configure command, and that both files are group writable: % su % chown mailman:mailman data/aliases* % chmod g+w data/aliases*
  • Hack your Postfix's main.cf file to include the following path in your alias_maps variable: /usr/local/mailman/data/aliasesNote that there should be no trailing .db. Do not include this in your alias_database variable. This is because you do not want Postfix's newaliases command to modify Mailman's aliases.db file, but you do want Postfix to consult aliases.db when looking for local addresses.You probably want to use a hash: style database for this entry. Here's an example: alias_maps = hash:/etc/postfix/aliases, hash:/usr/local/mailman/data/aliases
  • When you configure Mailman, use the --with-mail-gid=mailman switch; this will be the default if you configured Mailman after adding the mailman owner. Because the owner of the aliases.db file is mailman, Postfix will execute Mailman's wrapper program as uid and gid mailman.
That's it! One caveat: when you add or remove a list, the aliases.dbfile will updated, but it will not automatically run postfix reload.This is because you need to be root to run this and suid-root scripts are notsecure. The only effect of this is that it will take about a minute forPostfix to notice the change to the aliases.db file and update itstables.

bcf7231420
Reply all
Reply to author
Forward
0 new messages