Best way to filter parts of a email.message.Message

Tim Chase python.list at
Thu Sep 4 12:45:03 CEST 2014

On 2014-09-04 14:08, Chris Angelico wrote:
> On Thu, Sep 4, 2014 at 1:52 PM, Cameron Simpson wrote:
>> On 03Sep2014 20:59, Tim Chase wrote:
>>> - mime-parts can be nested, so I need to recursively handle them
>> Just to this. IIRC, the MIME part delimiter is supposed to be
>> absolute. That is, it will not occur in the nested subparts, if
>> any.
> I think the point here is that the validity check of a mime-part may
> involve checking sub-parts - eg the message is a mailing list digest
> (with one part per actual message), and some of those have
> attachments, which are to be stripped off if over 1MB.

Indeed, ChrisA divined my intent--an attachment remover based on
various types of mime-type and size tests.  A cursory search didn't
turn up any pre-existing utilities that did quite what I wanted.

Perhaps my previous message about detecting mbox-vs-maildir-vs-mh
format mailboxes hinted at this.  Thanks to all who answered there
(though I encountered a possible bug, as Claws Mail doesn't put
a .mh_sequences file in what it claims are MH local folders which
causes issues with MH() ).

So the goal is to keep the original message with highest fidelity
while still stripping out the undesirable attachments.

Thanks for your thoughts,


More information about the Python-list mailing list