Perl中使用MIME::Lite发送邮件实例

2019-10-01 11:50:46于丽

my    $msg = MIME::Lite->new(
From     => ‘xxx@163.com',

To       => ‘chenqing663@foxmail.com',

Cc       => ‘some@other.com, some@more.com',
Subject  => ‘hello,my first mail from chenqing.org',
Type  => ‘multipart/mixed',
Data =>' other data'
);

$msg->attach(
Type => ‘text/html',
Data => qq{
<body>
这是我的 <b>good</b> image:
<img src=”cid:logo.png”>
</body>
},
);

$msg->attach(
Type     => ‘image/png',
Disposition => ‘attachment',
Filename => ‘other.png',

Id => ‘logo.png',
Path => ‘/home/king/perl/logo.png'
);

MIME::Lite->send(‘smtp', $host, Timeout=>60,    AuthUser=>$user, AuthPass=>$pass);
$msg->send;

是不是很简单呢?