Re: Extract Attachment from Mail

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Cameron Simpson wrote:
On 12Feb2007 07:27, Patrick Steiner <patrick.steiner@xxxxxx> wrote:
| i fetch my mails via fetchmail and after that procmail sorts them into | different mailbox-folders.

"mail" is its own plural, like "sheep" or "fish".

| how can i extract attachments and but them into a folder like | ~/attachments? i tried mimeStrip.pl, but | i also get some non -base64 coded mails and the don't work with this | tool :-(. any ideas who i can extract
| this files?

I extract attachments using the metamail package (not available as a
Fedora package as far as I can tell - had to build it from source; I can
email you a tarball if you like).

I use a wrapper script to put the files somewhere
useful:

  http://www.cskk.ezoshosting.com/cs/css/bin/mailunpack

That script relies on a bunch of other things from that script collection.
You might just want to skip it for the metamail incantation.  If you want to
take it as-is, it may be easiest to just grab the whole css package:

  http://www.cskk.ezoshosting.com/cs/css/

I normally run this script from mutt but it could easily be used from a
procmail recipe.

Disclaimer: I wrote these scripts and thus am a bit biased.


You can do it in a few lines of perl with the MIME::Parser package (from CPAN, I don't think it is rpm-packaged). Something like this:


#Accept a mail message on stdin, split attachments into
# directory
use MIME::Parser;
### Create parser, and set some parsing options:
$archive='/path/for/attachments';
my $parser = new MIME::Parser;
### Change how nameless message-component files are named:
$parser->output_dir("$archive");
$parser->output_prefix('msg');
### Parse input:
$entity = $parser->parse(\*STDIN) or die "parse failed\n";



--
  Les Mikesell
   lesmikesell@xxxxxxxxx


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux