perl发送邮件

[不指定 2008/10/31 16:36 | by askwan ]
Mail::SendEasy这个模块在cpan邮件发送系列关注度比较高,用来发送邮件相当easy
它支持plain/html格式邮件内容,通过SMTP服务器发送邮件,对系统平台没有依赖,
支持附件发送和SMTP认证。

用法可以看它的perldoc
就它的例子做些解释

use Mail::SendEasy ;

  my $mail = new Mail::SendEasy(
  smtp => 'localhost' ,   #SMTP服务器
  user => 'foo' ,           #认证用户名
  pass => 123 ,           #认证密码
  ) ;
#SMTP端口默认为25,连接超时时间默认为120秒
  
  my $status = $mail->send(
  from    => 'sender@foo.com' ,   #发送者邮件地址
  from_title => 'Foo Name' ,         #发件人名字或标题
  reply   => 're@foo.com' ,           #回复信件地址
  error   => 'error@foo.com' ,        #发送出错信息地址
  to      => 'recp@domain.foo' ,     #接受邮件地址
  cc      => 'recpcopy@domain.foo' , # 接受邮件副本地址
  subject => "MAIL Test" ,         # 邮件主题
  msg     => "The Plain Msg..." ,  #文本格式邮件内容
  html    => "<b>The HTML Msg...</b>" , #html格式邮件内容,有这个则msg无效
  msgid   => "0101" , #给邮件头加一个ID号
  ) ;
  
  if (!$status) { print $mail->error ;}

作者:askwan@『AskWan』
地址:http://www.askwan.com/post/125/
可以转载,转载时请以链接形式注明作者和原始出处及本声明!

Scripts | Comments(0) | Trackbacks(0) | Reads(1053)
收藏到网摘:百度搜藏 Google书签 Yahoo收藏 新浪ViVi收藏夹 365天天网摘 天极网摘 我摘·网摘·网络书签 POCO网摘 和讯网摘 Bolaa博拉博客收录中心 天下图摘
Add a comment
Emots
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
Enable HTML
Enable UBB
Enable Emots
Hidden
Remember
Nickname   Password   Optional
Site URI   Email   [Register]