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

I have been using MIME::Entity to generate MIME emails to include attachments and the such. The problem I am running into is that I am not sure if MIME::Entity supports nested MIME Entries... I need to do the main Content Type as Multipart/Mixed, but embed a Multipart/Alternative within it... I read the man page for MIME::Entity but could not find any reference to this. Does anyone know how this might be posible?

Replies are listed 'Best First'.
Re: MIME Email Generation
by chromatic (Archbishop) on Dec 22, 2000 at 09:51 UTC
    According to the MIME-tools documentation (specifically the description), the whole bundle can create and parse even nested multipart messages.

    I bet the syntax would be something like:

    my $top = MIME::Entity->build({ To => 'you@there.pl' }); $top->attach(MIME::Entity->build({ Content-type => 'multipart/alternat +ive; boundary="abc123---" });
    ... but I don't have this installed, I haven't tried it, and my house smells like cleaning fluid.

    So give it a shot and I'll refund your money if it doesn't work.

      I actually used a combo of the above two posts, and it worked great, thanks!
Re: MIME Email Generation
by Fastolfe (Vicar) on Dec 22, 2000 at 09:45 UTC
    Yes, you can. Basically build your entities exactly as you'd expect, and use the 'add_part' method to attach one entity as a part of another multipart entity.
    $inner = new MIME::Entity ( ... ); $outer = new MIME::Entity ( ... ); $outer->add_part($inner);