[Mailman-Developers] Send message having same "References" from archive

Mark Sapiro mark at msapiro.net
Thu Sep 5 05:21:00 CEST 2013


On 08/18/2013 09:20 AM, VuNghia Truong wrote:
>
> Suppose that I have archive file, like "list_name.mbox".
> Now, I want to get the message with same "References" field, and send them
> out.
> How could I accomplish this problem?


from Mailman import Mailbox

mid = 'the message Id you're looking for'
fp = open('/path/to/list_name.mbox')
mb = Mailbox.Mailbox(fp)
msgs = []
for msg in mb:
    refs = msg.get_all('references')
        for ref in refs:
            if ref.find(mid) >= 0:
                msgs.append(msg)
                break

# At this point, msgs contains a list of email.Message.Message objects #
that contain 'the message Id you're looking for' in their References:
# Sending them is left as an exercise for the reader.

-- 
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-Developers mailing list