At 22:11 2002-12-23 -0500, Tephra Lynn Davis did say:
Ideally the process would go like this:
1. take all mail to graphics(_at_)somelistserv
2. put all attachments in ~/some/archive/directory
Perhaps even, say, a webdir, where the files therein can be accessed
via a webserver.
3. insert a "attachment archived: somefilename" statements into the text
Perhaps even, say, as a weblink (or ftp link):
Attachment archived: <http:/yourwebserver/somepath/filename>
Then the recipient can access the file by clicking on the weblink.
4. deliver mail to its proper directory
Step 3 is not required, it would be very nice however.
_changing_ multipart messages will require some footwork on your
part. This is best done by handing the message over to an external program
which simply does this. Procmail can facilitate this, but won't be
decoding and saving the attachment itself.
Step 2... I'm not sure which would be best, excluding HTML/text/other non-
target attachments or specifically stating to only archive certain file
extensions. Off the top of my head I need it to save jpg(jpeg), gif, bmp,
psp, psd, q5q, q9q, tub, ttf, and zip at the least.
I'd be prone to go with an exclusion list.
Also, I need to consider the possibility of multiple files with the same
name. Other than 'sig tags' the incidence should be low and I think
changing the storage directory periodically will avoid losing anything
'important' if I just let it overwrite old files.
Make the directory a date-based dir, and that will reduce a fair number of
the collisions. If the utility which pulls the attachments out is given
the smarts to, it wouldn't be difficult for it to add a cyclic pre-suffix
to files: filename-001.jpg, filename-002.jpg and whatnot, whenever a
filename collision is detected.
Date-based dirs can also simplify message purging, if you end up writing a
cron job to purge attachments over some certain age (assuming the mail
process is the only thing writing to these dirs). No need to rummage
through each file in a huge dir - just process the dirs by datecode. Of
course, manipulating individual files is okay too, but I'm not fond of dirs
with hundreds (or thousands) of files sitting in them.
However that does
require whatever program/script I use be able to either rename files or
overwrite them without question.
That it does...
I know how to do steps 1 and 4 of course, I just need help with the
important stuff in the middle. :) I have seen messages in the archives
about removing attachments and a few mention metamail for 'splitting off'
attachments but I don't know how to get from there to here.
Ya might want to search around for a program called "stripmime", which is a
small perl utility. Hack that up a bit to pass the chunks to an external
MIME decoder (or implement your own with a perl MIME library - there are
UUENCODED and BINHEX attachments are a whole 'nuther joy for you to consider.
Sean B. Straw / Professional Software Engineering
Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
Please DO NOT carbon me on list replies. I'll get my copy from the list.
procmail mailing list