<html><head></head><body>Well ain't that rich? To use an allegory of sorts, we're going to have start using staples rather than paperclips 📎🖇️ with our email attachments, and one unified digital signature on the whole message as sent rather than a separate signature for each enclosure as commonly "done" with PGP, GnuPG, etc.<br><br><div class="gmail_quote">On March 30, 2021 7:39:02 PM AKDT, Plutocrat <plutocrat@gmail.com> wrote:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">Still can't find the magic solution to this.<br><br>- My PERL isn't good enough to re-purpose strip-attachments.pl so it works on individual emails.<br>- ripmime works to extract attachments only<br>- altermime looked good and would delete all attachments from a directory of emails. However it messed up the structure somehow so they wouldn't display in an email client (Thunderbird, Roundcube).<br>- mimeDEFANG looked possible, but couldn't figure out how to use that as a standalone script.<br>- PHP solutions including the promising <a href="https://github.com/php-mime-mail-parser/php-mime-mail-parser">https://github.com/php-mime-mail-parser/php-mime-mail-parser</a> seem only to be able to save attachments from the email, not delete it.<br><br>I'll keep going I guess. I can't believe I'm the only person in the world to want to do this though ...<br><br>P.<br><br>On 19/03/2021 07.31, Joseph Tam wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;">On Thu, 18 Mar 2021, Plutocrat wrote:<br><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #ad7fa8; padding-left: 1ex;"> I've been looking around for a solution to this problem. I want to prune down the attachments on a server before a migration. Some of the emails are 7 years old and have 40Mb attachments, so this seems like a good opportunity to rationalize things. So perhaps I'd like to "Remove all attachments from emails older than 2 years, in the .Sent directory", or "Attachments over 10Mb anywhere in the mail tree"<br><br> I've found the strip_attachments.pl script here <<a href="https://fossies.org/linux/Mail-Box/examples/strip-attachments.pl">https://fossies.org/linux/Mail-Box/examples/strip-attachments.pl</a>> which works fine on mbox (as tested on my local Thunderbird mboxes), but not on maildir which is on the dovecot server. My Perl isn't strong enough to re-purpose it.<br></blockquote><br>It you have anything that works on mbox, it will probably work on Maildir<br>as each file can be considered a single message mbox. You can combine<br>the script with<br><br> find ~user/MailDir -type f ... -exec /path/to/mbox-strip {} \;<br><br>The ... can be replaced with more file tests (like minimum size or age<br>or only within */cur/) to cut down on processing.<br><br>I wrote a gawk script to slim down a multi-Gb Outlook mbox<br>for a user, but it wasn't really complicated, just matching for<br>/^Content-Transfer-Encoding:.*base64/i header (virtually all bulky data<br>will be encoded this way), buffering the base64 data part, then outputting<br>it if it was small, or deleting/replacing/extracting it otherwise.<br><br>It was a one-off discarded tool but I can hunt for it if you're hard up.<br><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #ad7fa8; padding-left: 1ex;"> I've looked at ripmime and mpack/munpack, and although they seem like useful tools to do the job of deconstructing the mail into its constituent parts, it doesn't seem to help in re-building the email. I think they could be used with a bit of study into mail MIME structure, and used with a helper script.<br><br> So before I take a deep dive into scripting my own solution, I just wanted to check if anyone else on the list has been through this and has some resources or pointers they can share, or maybe even someone to tell me "Duh, you can do it with doveadm of course".<br></blockquote><br>MIMEDefang may help.<br><br>Joseph Tam <jtam.home@gmail.com><br></blockquote></pre></blockquote></div><br>-- <br>Sent from my Android device with K-9 Mail. Please excuse my brevity.<br>-- <br>Sent from my Android device with K-9 Mail. Please excuse my brevity.</body></html>