Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
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. –  barrycarter 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. –  barrycarter Mar 25 '11 at 17:15
add comment

2 Answers 2

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)

share|improve this answer
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.