procmail
[Top] [All Lists]

Re: how to get the attachment part?

2001-12-05 01:36:03
At 08:16 2001-12-05 +0100, Andreas Sartori wrote:
i have a serious problem. i am getting a mail with 2 attachments every
3 weeks and i need to store them on disk.

anyone can help?

You haven't responded to the last person who responded to help you with your previous query, under the _other_ thread you started with basically this same question. You should really start there before asking for help again.

1. What the attachment names are is of little significant import -- properly sent, the message should contain the filenames.

2. Rather than deal with filename collision (previous message having sent the same filenames, etc), you could just extract the files from any given message into an incrementing named directory (1\filename, 2\filename - that is, all the files from the first message would be extracted into 1\, and then the next time you received one of these messages, they'd be extracted into 2\, etc). I posted the relatively simple ruleset for dealing with an incrementing counter in another message recently which inquired about taking an existing mailbox and splitting it into several smaller mailboxes. OTOH, if each time a new message arrives, the previous set of files are "outdated", you could extract to a subdir, and swap directories, retaining the previous version - i.e. always purge attach_backup, extract files to it, then swap attach_backup with attach_current.

3. procmail won't actually decode the attachments into files -- what you'd use is mimencode or similar -- see 'man mimencode'. Basically, procmail would locate the MIME chunks (I presume that this is what your attachments are arriving as) and pass the bodies of those chunks to mimencode to decode them, outputting to the filenames which procmail has extracted from the message. Better yet, procmail can just pass the entire message to an external MIME parser which deals with multipart.


Some rather pertinent threads can be found in the archives:

<http://www.rosat.mpe-garching.mpg.de/mailing-lists/procmail/1998-02/msg00181.html>

<http://www.rosat.mpe-garching.mpg.de/mailing-lists/procmail/1997-05/msg00595.html>


Basically, you'd use procmail to identify that this is the message which contains some attachments, and then you'd pass it to a program which deals with mime extraction. Find yourself a program that does that (it isn't procmail), read the man pages for it, experiment (save the mailbox with the test message you have and throw it at the test app several times using different options), and when you have an idea of what your chosen mime decoder works like, come back and ask for specific advice on how to use it it you aren't clear on the concept by then.

:0
* ^From:[       ]*someuser(_at_)domain\(_dot_)tld
* ^Content-Type:[       ]multipart/mixed
| some_decode_perlscript_or_shellscript

Where the script either directly decodes the message, or is a shellscript that changes dirs (perhaps with some passed argument) and decodes the message into the subdir. Whatever. The idea is that this procmail recipe would be triggered only on the message conditions matching the message in question, and it'd invoke the script against that message.

---
 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
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>