9

My saved-messages and sent-mail "folders" (actually Unix MBX files) are huge because of attachments, most of which I've saved to disk anyway.

I want to keep the messages, but replace the attachment w/ a text file saying "Attachment removed: /full/path/to/attach.txt".

How do I do this?

I'm using Alpine, but any tool that does this for Unix MBX is fine. Alpine does let me delete attachments from emails, but I can't replace them w/ a text file. Notes:

  • I realize I can save the message to a file and edit the file using emacs, but that's kludgey and probably messes up "Content-Length" headers and stuff.

  • I also realize I can forward the message, with headers, to myself after removing the attachment. Again, kludgey.

  • I don't think Alpine lets me add attachments to stored mail (unless I want to send it somewhere [which messes up headers]), so I can't delete the big attachment and add a smaller one.

  • I realize I could write a Perl script to do this, but hoping for an existing well-tested solution.

  • 1
    Wow, you must be the other person in the universe that understands that email isn't a filesystem! – pboin Mar 25 '11 at 16:56
  • @pboin Unless, of course, you use M$ Outlook :( ... actually, some Unix mail programs use the Maildir/ format, where each message is a file, and mail folder is really a directory. –  Mar 25 '11 at 17:10
  • @forcefsck I know I can patch Alpine to use maildir but really don't want to. Plus, I still don't think that solves my problem. –  Mar 25 '11 at 17:15

2 Answers2

3

OK, I poked aorund, and when Alpine "deletes" an attachment, it actually replaces it with something like:

Content-Type: Text/Plain; charset=US-ASCII
X-Content-Type: image/jpeg
X-Content-Transfer-Encoding: base64
Content-ID: <part1.07020604.05000506@flamescape.com>

  [ The following attachment was DELETED when this message was saved:    ]
  [ A Image/JPEG segment of about 93,336 bytes.                          ]

I can then use emacs to edit this message (and it doesn't mess up any Content-Length headers or anything)

1

I use Thunderbird/icedove with the AttachmentExtractor add-on for this.