jc23 has asked for the wisdom of the Perl Monks concerning the following question:

Hey Monks,

Previously, I was trying to send a directory of mail at once. With help from you guys, I ended up with:

foreach my $dirContent ( @dirContents ) { #mail contents and attachment open (MESSAGE, "$dirContent"); my @message = <MESSAGE>; my $msg = MIME::Lite->new( From => $sender, To => $recipient, Subject => $dirContent, Data => \@message, Type =>'multipart/mixed' ); close ( MESSAGE ); $msg->send; } closedir ( CHANGEME ); exit (0);
This segment properly sends mail with contents from various mail files in the folder, however, if the original mail file contains an attachment, the attachment is not shown. Although $dirContent is an mail file to begin with, I think I still need to implement some kind of parsing from $dirContent to extract the attachment file and reattach it separately. I'm not sure how to do this using MIME::Lite and Mail::Audit. Could someone please give me some suggestions?

Thanks

jc

Replies are listed 'Best First'.
Re: Playing with attachments
by liz (Monsignor) on Jul 29, 2003 at 21:13 UTC
    ...however, if the original mail file contains an attachment, the attachment is not shown...

    And that's why I feel like you're reinventing the wheel. Exactly for this sort of reason, there are modules such as Mail::Box. It will handle those cases for you.

    Liz

Re: Playing with attachments
by jc23 (Acolyte) on Jul 29, 2003 at 21:46 UTC
    liz,

    Yes, there are modules that exist for such purposes. But I am not familiar with them. So that is why I am asking for pointers to the right modules to use because I don't want to reinvent the wheel. =)

    Anyone know what the differences around between Mail and MIME modules?Is MIME a subset of Mail? thanks.

      In 278628 you said: ...I have looked at Mail::Audit, Mail::Box, Mail::Parser, but can't seem to find what I need as they all seem to be fancy modules... which implies to me that you have looked at these modules.

      So I guess you already had pointers to the right modules.

      Maybe you should have a look at Mail::Box-Cookbook.

      Liz