If you want to have text and html versions of the message then you should combine them in mutipart/alternative. If you want to add an attachment then you should create multipart/mixed which would contain multipart/alternative with text and html, and attachment. So message structure should be as follows:
Here's the small example that shows how to create such message:multipart/mixed - multipart/alternative - text/plain - text/html - application/pdf or whatever you want
use strict; use warnings; use MIME::Lite; my $alternative = MIME::Lite->new( Type => 'multipart/alternative', ); $alternative->attach( Type => 'TEXT', Data => 'Message text', ); $alternative->attach( Type => 'text/html', Data => '<p><b>Message text</b></p>', ); my $message = MIME::Lite->new( Type => 'multipart/mixed', From => 'sender@example.com', To => 'rcpt@example.com', Subject => 'Example', ); $message->attach($alternative); $message->attach( Type => 'TEXT', Filename => 'passwd', Disposition => 'attachment', Path => '/etc/passwd', ); $message->print(\*STDOUT);
In reply to Re: MIME::Lite and Multipart
by zwon
in thread MIME::Lite and Multipart
by Analog
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |