?

Log in

No account? Create an account

Finally! - Journal of Omnifarious

May. 27th, 2004

10:16 am - Finally!

Previous Entry Share Next Entry

Finally, after having messed around with Mailman, and Postfix for many hours last night and this morning, I've managed to get email lists to work on my new system. Now I'm set to start moving users over to it. :-) That will probably happen this weekend.

In order to get it to work perfectly, I had to modify Mailman slightly. I would like the Mailman developers to accept my modification as a patch, because I think it's generally useful, but I'm not hopeful.

I put the following here because hozed wanted to see it.


It's really annoyed me that I can't create a list alias domain, like lists.omnifarious.org and still be able to refuse mail to list-name@omnifarious.org

So, I created a small patch to Mailman.MTA.Postfix that allows you to specify a prefix to be applied to all virtually hosted lists that show up in the omnifarious.org domain.

For example, I have set this prefix to 'mmlist_'. This is what my virtual-mailman file now looks like:

# STANZA START: list-name
# CREATED: Thu May 27 08:00:48 2004
list-name@lists.omnifarious.org              mmlist_list-name
list-name-admin@lists.omnifarious.org        mmlist_list-name-admin
list-name-bounces@lists.omnifarious.org      mmlist_list-name-bounces
list-name-confirm@lists.omnifarious.org      mmlist_list-name-confirm
list-name-join@lists.omnifarious.org         mmlist_list-name-join
list-name-leave@lists.omnifarious.org        mmlist_list-name-leave
list-name-owner@lists.omnifarious.org        mmlist_list-name-owner
list-name-request@lists.omnifarious.org      mmlist_list-name-request
list-name-subscribe@lists.omnifarious.org    mmlist_list-name-subscribe
list-name-unsubscribe@lists.omnifarious.org  mmlist_list-name-unsubscribe
# STANZA END: list-name

And, here is what my aliases file looks like:

# STANZA START: list-name
# CREATED: Thu May 27 08:00:48 2004
mmlist_list-name:             "|/var/list-name/mail/list-name post list-name"
mmlist_list-name-admin:       "|/var/list-name/mail/list-name admin list-name"
mmlist_list-name-bounces:     "|/var/list-name/mail/list-name bounces list-name"
mmlist_list-name-confirm:     "|/var/list-name/mail/list-name confirm list-name"
mmlist_list-name-join:        "|/var/list-name/mail/list-name join list-name"
mmlist_list-name-leave:       "|/var/list-name/mail/list-name leave list-name"
mmlist_list-name-owner:       "|/var/list-name/mail/list-name owner list-name"
mmlist_list-name-request:     "|/var/list-name/mail/list-name request list-name"
mmlist_list-name-subscribe:   "|/var/list-name/mail/list-name subscribe list-name"
mmlist_list-name-unsubscribe: "|/var/list-name/mail/list-name unsubscribe list-name"
# STANZA END: list-name

Yes, people can still send to mmlist_list-name@omnifarious.org, but I consider that an acceptable tradeoff since I'm now allowed a lot more detailed control over my omnifarious.org namespace.

The parameter's name is POSTFIX_VIRTUAL_PREFIX, and it's expected to be set in the mm_cfg file. If there is no POSTFIX_VIRTUAL_PREFIX set, it defaults to being blank, which gives you the original behavior for the Postfix MTA.


diff -u -r2.22 Postfix.py
--- Mailman/MTA/Postfix.py	14 Sep 2003 04:41:32 -0000	2.22
+++ Mailman/MTA/Postfix.py	27 May 2004 14:01:37 -0000
@@ -79,10 +79,18 @@
 
 
 
-def _addlist(mlist, fp):
+def _addlist(mlist, fp, virt=False):
     # Set up the mailman-loop address
     loopaddr = Utils.ParseEmail(Utils.get_site_email(extra='loop'))[0]
     loopmbox = os.path.join(mm_cfg.DATA_DIR, 'owner-bounces.mbox')
+    # Arrange for the virtual prefix to be added if needed.
+    if virt:
+        try:
+            virt = mm_cfg.POSTFIX_VIRTUAL_PREFIX
+        except:
+            virt = ''
+    else:
+        virt = ''
     # Seek to the end of the text file, but if it's empty write the standard
     # disclaimer, and the loop catch address.
     fp.seek(0, 2)
@@ -109,11 +117,14 @@
     # Now add all the standard alias entries
     for k, v in makealiases(listname):
         # Format the text file nicely
-        print >> fp, k + ':', ((fieldsz - len(k)) * ' ') + v
+        print >> fp, virt + k + ':', ((fieldsz - len(k)) * ' ') + v
     # Finish the text file stanza
     print >> fp, '# STANZA END:', listname
     print >> fp
 
+
+def _addvirtlist(mlist, fp):
+    _addlist(mlist, fp, True)
 
 
 def _addvirtual(mlist, fp):
@@ -123,6 +134,12 @@
     # Set up the mailman-loop address
     loopaddr = Utils.get_site_email(mlist.host_name, extra='loop')
     loopdest = Utils.ParseEmail(loopaddr)[0]
+    # Set up the virtual prefix, if any
+    virt = ''
+    try:
+        virt = mm_cfg.POSTFIX_VIRTUAL_PREFIX
+    except:
+        pass
     # Seek to the end of the text file, but if it's empty write the standard
     # disclaimer, and the loop catch address.
     fp.seek(0, 2)
@@ -147,7 +164,7 @@
     for k, v in makealiases(listname):
         fqdnaddr = '%s@%s' % (k, hostname)
         # Format the text file nicely
-        print >> fp, fqdnaddr, ((fieldsz - len(k)) * ' '), k
+        print >> fp, fqdnaddr, ((fieldsz - len(k)) * ' '), virt + k
     # Finish the text file stanza
     print >> fp, '# STANZA END:', listname
     print >> fp
@@ -226,9 +243,11 @@
         lock.lock()
     # Do the aliases file, which need to be done in any case
     try:
-        _do_create(mlist, ALIASFILE, _addlist)
         if mlist and mlist.host_name in mm_cfg.POSTFIX_STYLE_VIRTUAL_DOMAINS:
+            _do_create(mlist, ALIASFILE, _addvirtlist)
             _do_create(mlist, VIRTFILE, _addvirtual)
+        else:
+            _do_create(mlist, ALIASFILE, _addlist)
         _update_maps()
     finally:
         if lock:

Current Mood: [mood icon] accomplished

Comments:

[User Picture]
From:hozed
Date:May 27th, 2004 10:21 am (UTC)
(Link)
awww, I wanted to see the patch ;)
(Reply) (Thread)
[User Picture]
From:omnifarious
Date:May 27th, 2004 10:36 am (UTC)
(Link)

There, I put it in. :-)

(Reply) (Parent) (Thread)
[User Picture]
From:hozed
Date:May 27th, 2004 10:39 am (UTC)
(Link)
You credited the wrong hozer ;)
(Reply) (Parent) (Thread)
[User Picture]
From:omnifarious
Date:May 27th, 2004 11:13 am (UTC)
(Link)

Oops. I always get your name wrong. :-(

(Reply) (Parent) (Thread)
[User Picture]
From:merchanta
Date:May 27th, 2004 06:16 pm (UTC)
(Link)
I saw this post, and I saw 6 comments, and I thought, "I bet Troy responded to that."

I know thee so well.
(Reply) (Parent) (Thread)
[User Picture]
From:omnifarious
Date:May 27th, 2004 06:24 pm (UTC)
(Link)

*chuckle* rosencrantz319 always responds to these sorts of posts as well, though for a different reason. I'm not sure what the reason is, but his posts are always at least faintly amusing. :-)

(Reply) (Parent) (Thread)
[User Picture]
From:merchanta
Date:May 27th, 2004 06:25 pm (UTC)
(Link)
Yes, indeed. :)
(Reply) (Parent) (Thread)
[User Picture]
From:omnifarious
Date:April 4th, 2007 04:30 am (UTC)
(Link)

I've been trying to talk to you now for weeks. :-( I would really like to reconnect someday.

(Reply) (Parent) (Thread)
From:rosencrantz319
Date:May 27th, 2004 05:37 pm (UTC)
(Link)
(Reply) (Thread)
[User Picture]
From:omnifarious
Date:May 27th, 2004 05:50 pm (UTC)
(Link)

*laugh*

(Reply) (Parent) (Thread)