Thanks, I tried using MIME-Tools-5.4.11.tar.gz
I'm facing an interesting problem. I'm using the following code to dump the
mail.
Now I'm receiving a file "encrypted.txt" in mail as attachment. The code
works fine & it dumps the contents & the attachment also.
I have set my .procmailrc as

:0 c
|perl DumpMail.pl >DumpMail.txt
:0
|perl Customizer.pl

Now in Customizer.pl I want to use the attachment "encrypted.txt" , but it
tells me that file does not exist which is actually seen
on doing ls. Kindly guide me to rectify this problem.

Thanks & Regards,
Priyanka

-------------------- CODE of DumpMail.pl starts
here ---------------------------------------------

#!/usr/bin/perl

use MIME::Parser;

#------------------------------
#
# dump_entity ENTITY, NAME
#
# Recursive routine for dumping an entity.
#
sub dump_entity {
    my ($entity, $name) = @_;
    defined($name) or $name = "'anonymous'";
    my $IO;

    # Output the head:
    print "\n", '=' x 60, "\n";
    print "Message $name: ";
    print "\n", '=' x 60, "\n\n";
    print $entity->head->original_text;
    print "\n";

    # Output the body:
    my @parts = $entity->parts;
    if (@parts) {                     # multipart...
 my $i;
 foreach $i (0 .. $#parts) {       # dump each part...
     dump_entity($parts[$i], ("$name, part ".(1+$i)));
 }
    }
    else {                            # single part...

 # Get MIME type, and display accordingly...
 my ($type, $subtype) = split('/', $entity->head->mime_type);
 my $body = $entity->bodyhandle;
 if ($type =~ /^(text|message)$/) {     # text: display it...
     if ($IO = $body->open("r")) {
  print $_ while (defined($_ = $IO->getline));
  $IO->close;
     }
     else {       # d'oh!
  print "$0: couldn't find/open '$name': $!";
     }
 }
 else {                                 # binary: just summarize it...
     my $path = $body->path;
     my $size = ($path ? (-s $path) : '???');
     print ">>> This is a non-text message, $size bytes long.\n";
     print ">>> It is stored in ", ($path ? "'$path'" : 'core'),".\n\n";
 }
    }
    1;
}

#------------------------------
#
# main
#
sub main {
    print STDERR "(reading from stdin)\n" if (-t STDIN);

    # Create a new MIME parser:
    my $parser = new MIME::Parser;

    # Create and set the output directory:
    (-d "mimedump-tmp") or mkdir "mimedump-tmp",0755 or die "mkdir: $!";
    (-w "mimedump-tmp") or die "can't write to directory";
    $parser->output_dir("mimedump-tmp");

    # Read the MIME message:
    $entity = $parser->read(\*STDIN) or die "couldn't parse MIME stream";

    # Dump it out:
    dump_entity($entity);
}
exit(&main ? 0 : -1);

#------------------------------
1;



-------------------- CODE ends
here ---------------------------------------------




----- Original Message -----
From: David L. Nicol <[EMAIL PROTECTED]>
To: Priyanka porwal <[EMAIL PROTECTED]>
Sent: Tuesday, July 17, 2001 2:08 AM
Subject: Re: saving attachments of mail in MIME format


> Priyanka porwal wrote:
> >
> > Hi,
> > I'm facing a problem in receiving mails. I'm sending mail in MIME format
with attachments. Now I want to receive this mail on server side & save the
attachment separately with different names.
> >
> > Kindly help.
> >
> > Regards,
> > Priya
>
>
> search for "munpack"
>
>
> --
>                                            David Nicol 816.235.1187
>                       Irish Government Warning: SMOKERS DIE YOUNGER

Reply via email to