use MIME::Entity; my $html = "\n
\n\n\nThis is some text\n\n\n"; my $text = "This is some text\n"; ### Create the top-level, and set up the mail headers: $top = MIME::Entity->build(Type => "multipart/alternative", From => 'me@myhost.com', To => 'you@yourhost.com', Subject => "Hello World!"); $top->attach(Data => $text, Type => "text/plain", Encoding => "quoted-printable"); $top->attach(Data => $html, Type => "text/html", Encoding => "quoted-printable"); $top->print(\*STDOUT); __DATA__ Content-Type: multipart/alternative; boundary="----------=_1020843667-205993-0" Content-Transfer-Encoding: binary MIME-Version: 1.0 X-Mailer: MIME-tools 5.316 (Entity 5.212) From: me@myhost.com To: you@yourhost.com Subject: Hello World! This is a multi-part message in MIME format... ------------=_1020843667-205993-0 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: quoted-printable This is some text ------------=_1020843667-205993-0 Content-Type: text/html Content-Disposition: inline Content-Transfer-Encoding: quoted-printable
This is some text ------------=_1020843667-205993-0--