Mailman Module for multiple virtual servers

17 posts / 0 new
Last post
#1 Sun, 10/23/2011 - 13:43
wrightsonm

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.

test@domain1.com test@domain2.com

(see http://www.virtualmin.com/node/16982)

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:

test_domain1.com test_domain2.com

however CPanel will set the mail aliases correctly. as test@domain1.com, test@domain2.com.

Looking at the following virtualmin-mailman config page: http://domain.com:10000/virtualmin-mailman/index.cgi?show=domain.com The add mailing list section requests a listname i.e. "test" and a domain name i.e."domain1.com"

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 "test_domain1.com"

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 ./virtualmin-mailman-lib.pl

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

Thanks

Mark

Sun, 10/23/2011 - 16:56
wrightsonm

Ok I have made some mods to the file: /usr/libexec/webmin/virtualmin-mailman/virtualmin-mailman-lib.pl

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: http://wp.voltnet.co.uk/virtualmin-mailman-for-multiple-virtual-domains

Mon, 10/24/2011 - 09:59
andreychek

Howdy,

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.

-Eric

Mon, 10/24/2011 - 17:31
JamieCameron

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.

''

Tue, 10/25/2011 - 08:46
wrightsonm

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:

listname: test_domain1.com list email address: test@domain1.com

test_domain1.com-request@domain1.com test_domain1.com-bounces@domain1.com test_domain1.com-owner@domain1.com

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: See: http://mail.python.org/pipermail/mailman-users/2003-February/026221.html

and then:

http://www.postfix.org/ADDRESS_REWRITING_README.html

I hope to look into this more, maybe tomorrow.

Mark

Tue, 10/25/2011 - 12:24
wrightsonm

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!

Thanks Mark

Tue, 10/25/2011 - 12:36 (Reply to #6)
JamieCameron

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

''

Tue, 10/25/2011 - 20:05
wrightsonm

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:

test_domain1.com@domain1.com test@domain1.com
test_domain1.com-bounces@domain1.com test-bounces@domain1.com
test_domain1.com-owner@domain1.com test-owner@domain1.com
etc

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 "test_domain1.com"

2. modified /usr/lib/mailman/Mailman/MailList.py 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 "test_domain1.com"

See the attached python file. It was written and placed in the mailman bin directory next to "withlist"
/usr/lib/mailman/bin/rename_list.py

The command to run this script is:


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

2. Modify MailList.py

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 test_domain1.com
#and the host_name is domain1.com then it is a special case
#correct the email address from test_domain1.com-extra@domain1.com
#to test-extra@domain1.com

if d is not None:
print d.group(1)
if extra is None:
return '%s@%s' % (d.group(1), self.host_name)
return '%s-%s@%s' % (d.group(1), extra, self.host_name)
else:
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:
GetMemberAdminEmail()
GetConfirmEmail()

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

Mark

References:
http://www.gnu.org/s/mailman/todo.html (Virtual Domain Support is on the Mailman todo list!)
http://mail.python.org/pipermail/mailman-users/2008-January/059939.html (possible issue with the genaliases command)
http://mail.python.org/pipermail/mailman-users/2011-June/071708.html (change real_name)
https://support.mayfirst.org/ticket/249 (editing email templates)
http://www.mail-archive.com/mailman-users@python.org/msg37220.html (emailaddr variable in email templates)
http://manpages.ubuntu.com/manpages/maverick/man8/withlist.8.html (with list man page)
http://docs.python.org/howto/regex.html#regex-howto (regex expression guide)

Tue, 10/25/2011 - 21:58 (Reply to #8)
JamieCameron

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

''

Wed, 10/26/2011 - 03:29
wrightsonm

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/MailList.py 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!

Mark

Wed, 10/26/2011 - 19:19 (Reply to #10)
JamieCameron

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?

''

Thu, 10/27/2011 - 03:02
wrightsonm

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 MailList.py 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 MailList.py 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 MailList.py.

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 _domainname.com is removed as it cleans up the User Interface.

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

Mark

Thu, 10/27/2011 - 22:32 (Reply to #12)
JamieCameron

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?

''

Fri, 10/28/2011 - 06:05
wrightsonm

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.

See http://mail.python.org/pipermail/mailman-announce/2011-September/000164.html

I may download and take a look sometime next week:

http://launchpad.net/mailman/3.0/3.0.0a8/+download/mailman-3.0.0a8.tar.gz

Mark

Wed, 07/25/2012 - 16:46
mgjk

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?

Thanks,

Wed, 10/17/2012 - 01:28
reivax

Hello,

is there any solution expected in future updates?

Wed, 10/17/2012 - 05:08
wrightsonm

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.

Regards

Mark

Topic locked