Chinaunix

标题: perl编程技巧:发送HTML格式邮件 [打印本页]

作者: 轩辕砍刀    时间: 2003-06-09 14:39
标题: perl编程技巧:发送HTML格式邮件
如果要发送html格式的邮件,可以用如下方法(应使用sender.pm新版本:0.703以
上):
use Mail::Sender;
open IN, $htmlfile or die "Cannot open $htmlfile : $!
";打开一个
html文本
$sender = new Mail::Sender {smtp =>; 'mail.yourdomain.com'};
$sender->;Open({ from =>; 'your@address.com',
to =>; 'other@address.com',
subject =>; 'HTML fiel',
headers =>; "MIME-Version: 1.0
Content-type: text/html

Content-Transfer-Encoding: 7bit" #定义了MIME头,表示这是一个HTML文
本。
}) or die $Mail::Sender::Error,"
";
#以下读取HTML文件的每一行,然后发送。
while (<IN> { $sender->;Send($_) };
close IN;
$sender->;Close(); #关闭




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2