my $html_filename = 'datei.html';
my $html;
if (open (my $htmlfh, '<', $html_filename)) {
# Einlesen in einem Zug; siehe Perl Cookbook in
local $/ = undef;
$html = <$htmlfh>;
close($htmlfh);
}
else {
warn "Kann Datei $html_filename nicht oeffnen $!";
}
my $msg = MIME::Lite->new(
To =>'you@yourhost.com',
Subject =>'Text und HTML mit Bildern!',
Type =>'multipart/alternative'
);
### plain text
my $textpart = $msg->attach(Type => 'text/plain',
Data => [
"Blah\n",
"Blubb\n"
]);
### HTML
my $htmlpart = $msg->attach(Type => 'multipart/related');
$htmlpart->attach(Type => 'text/html',
Data => [ $html ]);
$htmlpart->attach(Type => 'image/gif',
Path => '/path/zu/bildern/Bild.gif',
Id => 'Bild1');