[Alpine-info] Strip attachments from sent-mail

jason-alpine-info at shalott.net jason-alpine-info at shalott.net
Fri Jul 1 17:49:40 PDT 2022




> Hello list. Does anyone know of a simple way to strip attachments from

> sent-mail? Either through Alpine or some other means. I'm using Maildir

> by the way.


You can manually delete attachments from an individual message directly in
Alpine. While viewing a message, use ">" to go to the attachment screen,
select each attachment and "D" to delete it. (You'll get a message at
this point about Saving the message, and you'll see a "S)ave" option on
the screen -- do NOT use Save at this point...) Jump back to the main
message screen with "<", and _then_ "S"ave the message. Save it back to
the same folder it's already in ("sent-mail" or whatever). The original
copy will at this point be deleted (assuming the default "Save Will
Delete"), and a new copy, with the attachments replaced by a short
message, will be created in the same folder. e"X"punge, and you're done.


If you want to do this to an entire mailbox, I don't think that Alpine can
do it. However, if you have raw filesystem access to the mailspool, and
you're using Maildir, it's quite easy to script.

There are plenty of tools and modules out there that can strip MIME
attachments. One random example is: https://pldaniels.com/altermime/

Assuming you've installed altermime above, and assuming your sent-mail is
in ${HOME}/Maildir/.sent-mail/, you could strip all the attachments with a
command like:

find ${HOME}/Maildir/.sent-mail/{new,cur} -type f -exec altermime --removeall --input=\{\} \;

(Note that this will probably violate some of Maildir's atomicity
guarantees (e.g., if the host crashes while this is running, a message may
be corrupted; if you open the mailbox while a message is being processed,
your mail reader may get confused; etc). Working around this to preserve
Maildir's atomicity guarantees is pretty straightforward, but left as an
exercise to the reader...)


-Jason




More information about the Alpine-info mailing list