On Mon, Mar 21, 2022 at 01:28:28PM +0100, Martin Trautmann <tr...@gmx.de> wrote:

> Am 2022-03-21 um 12:56 schrieb raf:
> > textmail can probably do at least some of what you want:
> > 
> >    https://raf.org/textmail
> >    https://github.com/raforg/textmail
> > 
> > and it has some extensibility so you can supply external
> > translation programs for the bits it doesn't do.
> > 
> > it can operate on individual mail messages or mbox files.
> > check the output carefully. :-)
> 
> Thanks, that looks very helpful to strip attachments, to remove headers
> and to convert message bodies - but it lacks the option to perform a
> search and replace on message bodies!?

The -C option lets you supply a custom external
"attachment translation" program. That might help.
Something like "-C text/plain:txt:cmd". You just need
to write the "cmd" program in the language of your
choosing. If it doesn't work, you could modify textmail
to do what you need (rather than writing the whole
thing) if you like perl.

And it might not work. "Converting" to the same
mimetype might send it into an infinite loop. :-) I
don't think so, but custom translations are done before
the built-in ones, so you might need to run textmail
twice.

I just had a look at your original post. textmail does
(1) well. It even detects vestigial text alternatives
and doesn't replace html with them. (2) would require a
custom translator (but it wouldn't have access to the
headers so it can't do the "bonus" part (as is)). it
can't delete headers based on their content (as is),
only their names, so (3) can't be done as stated.
however, you can probably identify the names of headers
that are likely to be that long and supply a list of
those names.

If you try it and run into problems, let me know (off list)
and we can probably get it to work.

cheers,
raf

Reply via email to