Sendmail

From Hurlster Wiki
Jump to navigation Jump to search

Send email with inline image

#!/usr/bin/perl -w
use MIME::Lite;
### Create the multipart "container":
$msg = MIME::Lite->new(
    From    =>'root@company.com',
    To      =>'address@email.com',
#    Cc      =>'some@other.com, some@more.com',
    Subject =>'A message with inline image',
    Type    =>'multipart/related'
);
$msg->attach(
    Type => 'text/html',
    Data => qq{
        <body>
            Here's <i>my</i> image:
            <img src="cid:image.png">
        </body>
    },
);
$msg->attach(
    Type => 'image/png',
    Id   => 'image.png',
    Path => '/var/www/mrtg/image.png',
); 
$msg->send; # send via default