http://qs321.pair.com?node_id=1155577

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

Hello monks, Im trying to send an email which has both html and plaintext in the body. I'm using MIME::entity and Mail::Mailer. Simplified code:
use MIME::Entity; use Mail::Mailer qw(sendmail); my $email = MIME::Entity->build(Type => "multipart/alternative", To => 'somebody@example.com', subject => "Test Email"); $email->attach(Data => ["THIS IS DIRECTLY ATTACHED TEXT"], Type => "text/plain; charset=UTF-8", Encoding => "quoted-printable"); $email->attach(Data => ["<h2>THIS IS HTML TEXT<h2>"], Type => "text/html; charset=UTF-8", Encoding => "quoted-printable"); $email->print(\*STDOUT); $email->send;
When I check my email, I get only the html part to show. The plain text part disappears. However, if I remove the html part, the plain text part shows fine. Is this the right way to send combined text/html emails? I'm afraid I might be doing something stupid. The output of MIME::Entity is:
Content-Type: multipart/alternative; boundary="----------=_1455820701- +7549-0" Content-Transfer-Encoding: binary MIME-Version: 1.0 X-Mailer: MIME-tools 5.414 (Entity 5.414) To: somebody@example.com Subject: Test Email This is a multi-part message in MIME format... ------------=_1455820701-7549-0 Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable THIS IS DIRECTLY ATTACHED TEXT= ------------=_1455820701-7549-0 Content-Type: text/html; charset=UTF-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable <h2>THIS IS HTML TEXT<h2>= ------------=_1455820701-7549-0--
Thanks for any help!