Kwtgame.blog.chinaunix.net
hjjie2006
全部博文(271)
sersync++(0)
rsync++(3)
pptpd++(0)
awstats(1)
Varnish(0)
nginx(5)
Tomcat(1)
Apache(11)
Vsftp(5)
SVN++(3)
CVS++(0)
haproxy(0)
lvs(3)
cmd/other(2)
Ntop(0)
bandwidthd(1)
snmp(3)
Smokeping(1)
Nagios(2)
cacti(7)
Postfix(0)
Kerio MailServer(0)
sendmail(1)
sed awk(6)
DELL(1)
code(0)
up(0)
bat批处理(3)
win2003服务器必(2)
字符处理(6)
面试集锦(2)
linux shell编程(18)
2016年(2)
2015年(12)
2014年(7)
2013年(19)
2012年(22)
2011年(81)
2010年(128)
xcc314
RHCE520
jacklin0
sosozhuz
ygl23
gogo407
南非蜘蛛
jerryfun
xyaxlz
panic
mhy_183
普通人刘
kulxue20
franz
wb123456
zhezhe20
1cpuer
jieyanca
分类: Python/Ruby
2011-01-10 13:44:18
#!/usr/bin/perluse Net::SMTP;my $mailhost = "smtp.126.com"; # the smtp hostmy $mailfrom = 'xxx@126.com'; # your email addressmy @mailto = ('xxxx@163.com'); # the recipient listmy $subject = "标题";my $text = "正文\n第二行位于此。";#$smtp = Net::SMTP->new($mailhost, Hello => 'localhost', Timeout => 120, Debug => 1);$smtp = Net::SMTP->new($mailhost, Hello => 'localhost', Timeout => 120);# anth login, type your user name and password here$smtp->auth('126user','126password');foreach my $mailto (@mailto) { # Send the From and Recipient for the mail servers that require it $smtp->mail($mailfrom); $smtp->to($mailto); # Start the mail $smtp->data(); # Send the header $smtp->datasend("To: $mailto\n"); $smtp->datasend("From: $mailfrom\n"); $smtp->datasend("Subject: $subject\n"); $smtp->datasend("\n"); # Send the message $smtp->datasend("$text\n\n"); # Send the termination string $smtp->dataend();}$smtp->quit;###########################所需安装模块#use Net::SMTP#Authen::SASL###########################$stmp->auth('user','pass');#大部分SMTP服务器为了防止 spam /垃圾邮件,就需要用户验证身份。#此方法需要另外安装模块:Authen::SASL, 此模块可能系统不自带###########################Debug => 1#此段代码用于测试之用,所以开启了Debug,一般测试一次完毕,正式使用的话会关闭它。
上一篇:perl 磁盘检测.pl
下一篇:ascii
chinaunix网友2011-03-09 13:34:19
很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com
登录 注册