一只小白鼠

博客园 首页 新随笔 联系 订阅 管理

perl 脚本 发送邮件

 

代码
#!/usr/bin/perl -w
use Mail::Sender;
open my $DEBUG, ">> /tmp/mail.log" or die "Can't open the debug file: $!\n";
$sender = new Mail::Sender
{smtp
=> 'smtp_server',
from
=> 'send@mail.com'};
#发送普通邮件
$sender->MailMsg(
{to
=> 'NinGoo@test.com',
subject
=> 'test mail',
msg
=> 'hello word',
debug
=> $DEBUG
});
#发送带附件的邮件
$sender->MailFile(
{to
=> 'NinGoo@test.com',
subject
=> 'test mail with attached file',
msg
=> 'hello word',
file
=> '/tmp/test.txt'
debug
=> $DEBUG
});

 

posted on 2009-12-15 13:17  一只小白鼠  阅读(244)  评论(0编辑  收藏  举报