[Mailman-Users] Hide sender but keep reply-to sender address?

Mark Sapiro mark at msapiro.net
Mon Mar 11 20:35:21 CET 2013


Andrei wrote:

>OK, thanks. Does anybody has a custom handler like that and is willing
>to share? I have no idea how to do this.


Something like this
--------------------------------------------------------------------
from email.Utils import formataddr, getaddresses, parseaddr

def process(mlist, msg, msgdata):
    orig_from = parseaddr(msg.get('from'))
    orig_rt = msg.get_all('reply-to')
    del msg['from']
    msg['From'] = formataddr((mlist.description, mlist.GetListEmail()))
    del msg['reply-to']
    if orig_rt:
        rt_list = getaddresses(orig_rt)
        rt_addr = [x[1] for x in rt_list]
        if orig_from[1] not in rt_addr:
            rt_list += [orig_from]
    else:
        rt_list = [orig_from]
    msg['Reply-To'] = ', '.join([formataddr(x) for x in rt_list])
---------------------------------------------------------------------

should do it. This will add the From: address to any existing Reply-To:
if it isn't already there or create a Reply-To: if there wasn't one.
It can go pretty much anywhere in the pipeline before ToDigest, but
immediately before is good.

The list's anonymous_list and first_strip_reply_to must be No, and
reply_goes_to_list must be Poster.

-- 
Mark Sapiro <mark at msapiro.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