geektron has asked for the wisdom of the Perl Monks concerning the following question:
I've read through the perldoc for MIME::Lite and used the following to contruct the email:
the problem with the code: the HTML portion isn't coming through. using 'multipart/mixed' does send both portions, renders the HTML mail, but (as expected) attaches the text portion of the email -- which isn't the behavior i want.my $mailObj = MIME::Lite->new( From => 'firstname.lastname@example.org', To => $email, Subject => "subject line here", Type => 'multipart/alternative' ); $mailObj->attach( Type => 'text/html', Data => $htmlMail, ); $mailObj->attach( Type => 'text/plain', Data => $textMail, ); $mailObj->send();
i'm sure i'm missing something, but i'm not sure which direction i need to go.
EDIT: the problem is isolated to Thunderbird. Outlook handles the message appropriately, but Thunderbird ignores the HTML content.
EDIT 2: the problem is Thunderbird. it displays the last recognized MIME type, so if the message is built as above, the text-only portion is displayed. reversing the order builds a message so that Thunderbird does, in fact, display the HTML when 'Show Original HTML' is selected as the preference. (per this mozillazine.org forum post)