[Mailman-Users] Having mailman treat two domains as equal duringmigration...

Mark Sapiro msapiro at value.net
Fri Oct 28 18:51:42 CEST 2005


Mike Cisar wrote:
>
>What I would like to do is do a one-shot conversion of all the users to the
>new domain name and then internally to mailman, when the message is first
>submitted into the mailman process simply have a regex replacement of the
>sender's domain name so even though the message might actually be coming
>from joeblow at olddomain.com mailman would read that in, do a quick replace in
>its mind and for the rest of the process treat the message as if it had come
>from joeblow at newdomain.com 
>
>I am assuming that this should pretty much be a 'one-liner' code
>modification to mailman.   Pardon my Perl (I'm not a native Pythoner so that
>doesn't help matters :-) but the equivalent of "sender =~
>s/olddomain/newdomain/" immediately after mailman parses 'sender' from the
>incoming message.  I don't really grok how the message flows through the
>internals of Mailman... so the couple of places I've tried putting the
>'one-liner' don't seem to have any effect.  I'm assuming that this should be
>done literally as soon as possible after Mailman has received the message
>from the MTA to ensure that the substitution is used in all possible
>processes?
>
>I'm hoping someone on the list may be able to tell me if this a) is really a
>one-liner and b) roughly where to look at inserting the 'one-liner' in order
>to acchieve the required result.  

Well, maybe a two liner :)

Aside --------------------------
Actually, John Dennis' reply suggesting rewriting the address in the
MTA is a good one. The way I read your original, his concern about
replies is not relevant as I think you said the users already receive
mail addressed to either domain.

In spite of my agreement that John's suggestion is probably best, there
is one small caveat. If you have USE_ENVELOPE_SENDER = Yes in
mm_cfg.py, you'll have to rewrite the envelope sender too, and I don't
know if you can do that.

In any case, I'd already written most of the following before I saw
John's reply, so rather than let it go to waste ...   :)
End aside -----------------------

It depends on what the desired result is. I'm not clear on whether you
want to actually change the domain in the From: and maybe elsewhere in
the message so when the message from user at old.domain goes out, it is
From: user at new.domain, or if you just want user at old.domain to be
considered equivalent to user at new.domain for the purpose of validating
list membership for posting.

The easy one is the latter, so for that I would look at
Mailman/Message.py in the get_sender() and get_senders() methods. In
get_sender(), I would do the replacement in 'address' just before

        if not preserve_case:
            return address.lower()
        return address

In get_senders(), I would again do it to 'address' in this loop where
the dots are

        for pair in pairs:
            address = pair[1]
            ...
            if address is not None and not preserve_case:
                address = address.lower()
            authors.append(address)

This will also cause other messages (e.g. auotoresponses and "your
message awaits approval") to go to the new domain, but I gather that
is not a problem.

If you want to do the former (rewrite the headers), I suggest one of
two things. Do it in the first handler in the pipeline which is
Mailman/Handlers/SpamDetect.py, or make a new handler (e.g.
Mailman/Handlers/MungDomain.py) to do it and insert the new handler at
the beginning of the pipeline with something like

GLOBAL_PIPELINE.insert(0, 'MungDomain')

in mm_cfg.py. This won't work for any list which has a 'pipeline'
attribute, but that is rare.

-- 
Mark Sapiro <msapiro at value.net>       The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan




More information about the Mailman-Users mailing list