Chinaunix首页 | 论坛 | 博客
  • 博客访问: 987271
  • 博文数量: 150
  • 博客积分: 3017
  • 博客等级: 少校
  • 技术积分: 3829
  • 用 户 组: 普通用户
  • 注册时间: 2011-11-19 14:40
个人简介

Now in Baidu WISE team

文章分类

全部博文(150)

文章存档

2014年(8)

2013年(31)

2012年(111)

分类: Python/Ruby

2012-04-01 11:12:15

Use MIME::Lite to send mail

点击(此处)折叠或打开

  1. package MailTracker;
  2. require Exporter;
  3. @ISA = qw (Exporter);
  4. @Exporter = qw(Send);


  5. use MIME::Lite;
  6. our $Mailer;
  7. our $msg;
  8. #my %args;
  9. sub new{
  10.     my $self = {};
  11.     shift;
  12.     my %args = (
  13.         From => 'from@x.com',
  14.         To => 'to@x.com',
  15.         Cc => 'cc@x.com',
  16.         Subject => 'PLS set subject name!!',
  17.         Type => 'text/html',
  18.         Encoding => 'base64',
  19.         Data => 'No data',
  20.         SMTPHost => 'smtpem4.x.net',
  21.         @_,
  22.     );
  23.     $msg = MIME::Lite->new(
  24.         From => $args{From},
  25.         To => $args{To},
  26.         Cc => $args{Cc},
  27.         Subject => $args{Subject},
  28.         Type => $args{Type},
  29.         Encoding => $args{Encoding},
  30.         Data => $args{Data}
  31.     );


  32.     bless ($self);
  33.     return $self;

  34. }
  35. sub Send{
  36.     $msg->send('smtp',"smtpem4.x.net");
  37. }
  38. 1;
 

阅读(888) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~