Mailman Module for multiple virtual servers

There is a known issue with mailman that you cannot have two lists with the same name i.e.


CPanel has a solution to this issue and i’d like to implement it in virtualmin.

CPanel will create the mailman lists with the listnames:

however CPanel will set the mail aliases correctly. as,

Looking at the following virtualmin-mailman config page:
The add mailing list section requests a listname i.e. “test” and a domain name i.e.“

In the file, /usr/libexec/webmin/virtualmin-mailman/add.cgi I see no reason why the two parameters above can’t be combined to form a new hybrid list name “”

What I am unsure about is where the command is sent to create the postfix aliases. (Delete.cgi should also be modified.)

I think most if not all of the required mods would be in the file ./

Please could I have some guidance on how I may “reliably” implement this fix? Feedback on my proposal would be very much appreciated!



Ok I have made some mods to the file:

See the attached file.

The changes are minimal but remove the problem of two virtual domains wanting a list called the same thing.

Feedback would be appreciated.

If the attachment fails, I have also posted this information on my personal blog:


Thanks for your post! I’m going to ask Jamie (who created that plugin, amongst other things) if he could post a comment on your solution there.


That’s a great idea … the next release of the mailman plugin for Virtualmin will include an optional setting based on your code to control if the domain name is appended to the list name or not.

I have found the flaw in my plan.

The email addresses that mailman uses in the “from” field are incorrect.

From the original example the from email addresses appear to be:

list email address:

etc etc etc

I don’t yet know the solution to this. Any ideas?

I’ve briefly seen something that states that Postfix is able to do address rewriting:

and then:

I hope to look into this more, maybe tomorrow.


Another minor issue I have detected is in Virtualmin.

When selecting a virtual server running the new version of mailman and then selecting mail aliases, the custom aliases appear in the list whereas before you had to click the “show special aliases” button. I have no idea what a “Special Alias” or how Virtualmin decides it is special.

Any advice here would be appreciated!


I see the cause of this … I will also fix it in the next release of the Mailman plugin.

Ok so I have done some research into the problem of the email address that are either in the from: field of an email or appear in the body of an email (i.e. the new signup email) or an email address that appears in the admin pages (i.e. moderator request pages)

The from addresses can be resolved using postfix canonical maps. Simply put, creating the file:

/etc/postfix/canonical and entering:

then running postmap /etc/postfix/canonical

This will resolve the from address problem but wont resolve the other problems.

All of the problems can be fixed by making some minor changes to mailman core files.

So far I have done 2 things:

  1. written a script that changes the real_name to “test” and leaves the list_name as “”

  2. modified /usr/lib/mailman/Mailman/ to correct the email address generation code

1. Rename real_name

The reason why I have done this, is because Cpanel does it. It neatens up the UI as only “test” is displayed instead of “”

See the attached python file. It was written and placed in the mailman bin directory next to “withlist”

The command to run this script is:

cd /usr/lib/mailman/bin ./withlist -r rename_list

2. Modify

I am still checking for other lines of code that need changing and i’m 90% certain it isn’t yet perfect.
nor is it properly tested!

At approx line 190 I changed the getListAddress() function for this one:

def getListAddress(self, extra=None): regex = re.compile('^(.*)_'+self.host_name+'$') d = regex.match(self.internal_name())
  	#if the format of internal_name is
  	#and the host_name is then it is a special case
  	#correct the email address from
  	if d is not None:
      if extra is None:
        return '%s@%s' % (, self.host_name)
      return '%s-%s@%s' % (, extra, self.host_name)
      if extra is None:
          return '%s@%s' % (self.internal_name(), self.host_name)
      return '%s-%s@%s' % (self.internal_name(), extra, self.host_name)

This function should detect for listnames of the format name_domain and set the email address accordingly.

Other functions that need looking at that I think will need some modification are:

At this moment in time Option 2 does not correct the from: email addresses.
It will be in there somewhere though!


References: (Virtual Domain Support is on the Mailman todo list!) (possible issue with the genaliases command) (change real_name) (editing email templates) (emailaddr variable in email templates) (with list man page) (regex expression guide)

Isn’t there a mailman per-list option that you can set to control the from address for messages sent by the list?

As far as I am aware, this is not the case. I’ve never seen an option to set email addresses in Mailman other than the admin and moderator email addresses.

Having looked through some of the mailman code, mailman in file /usr/lib/mailman/Mailman/
dynamically generates the email address from the hostname and internal_name fields. If there was a field with the email addresses already stored, I would have expected mailman to use that instead of generating it each time.

I could of course have missed something!


Right, you can only set the domain name … not the list name. I forgot about that.

Seems like updating the canonical file is the best solution?

I don’t think the canonical file is the best way to do things. It is an option but what it doesn’t do is get the email address correct in the body of any automated emails from -owner, -bounces, -request etc.

Changing the listAddress function in corrects both the from: email addresses aswell as any email addresses that MailMan automatically put in the body of an email. Also I can think of at least one scenario in the MailMan admin interface (the Administrative Request for Mailing List / Moderator Requests) where the -owner address is displayed. Without the mod to this address is displayed incorrectly.

I still need to do some checks through the rest of the mailman code and also look at the functions GetMemberAdminEmail() and GetConfirmEmail() in

What I know to be working (without canonical) is:

list from email correct
bounces from email correct
request from email correct
emails in new sign up email correct
emails in pending moderator requests correct

What I don’t know is whether the real_name of the list has any impact on the email addresses. I don’t think so. The real_name should however, still be customised so that the is removed as it cleans up the User Interface.

A small change to doesn’t seem too bad in my opinion. There are some much more complicated mods required in Apache to get suexec working for instance.


Modifying mailman is tricky for Virtualmin to do, as we would need to deal with re-applying the modification if Mailman is upgraded…

You might want to get in contact with mailman developers and users to see if there is some better solution?

At present this is the best solution. However, Mailman 3 is well on the way which will support virtual hosts.
Mailman 3.0 alpha 8 has been released recently and this will be last last alpha build, with the aim of becoming beta very soon. The team is looking at a 11/11/11 release date.


I may download and take a look sometime next week:


Was this introduced in the Plugin? I can’t see any settings for it.

Alternatively, was a feature introduced to provide this kind of support?



is there any solution expected in future updates?

This is not implemented in the mailman plugin and v3 of mailman is still not yet out almost a year since I raised this issue. Mailman 3 is in beta but there is not an official date for it’s release. I am still running mailman on my server with the mod as described above without any issues.

I believe my solution won’t be implemented by Virtualmin as it involves mods to mailman itself. Mailman v3 however will support my changes and virtualmin will undoubtedly gain v3 support aswell.