lqxue

          常用鏈接

          統計

          book

          tools

          最新評論

          linux 下用 perl 發email

          首先,在linux上安裝perl-Mail-Sendmail-0.79-1.0.rh9.rf.noarch.rpm

          perl 代碼如下:

          #
          !/usr/bin/perl 
          use Mail::Sendmail; 
          $delay = 1;
          $f_list="list.txt";
          $line = 0;#skip the column title line
          my $subject="xxx";
          open(FILE,$f_list|| die "Can not open list file\n";
          while(<FILE>){
          chomp;
          $line=$line+1;
          next if($line==1);

          (
          $email,$passwd,$username,$yonghuming= split(/,/);


          %mail = (
              from 
          => 'xxx@xxx.com',
              to 
          => $email,
              subject 
          => $subject,
              
          'content-type' => 'text/html; charset="gbk"',
                  );
          $mail{body} = <<END_OF_BODY;
          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
          "http://www.w3.org/TR/html4/loose.dtd">
          <html>
          <head>
          <meta http-equiv="Content-Type" content="text/html; charset=gbk">
          <title>個人郵箱登陸</title>
          <style type="text/css">
          <!--
          body {
              margin
          -left: 0px;
              margin
          -top: 0px;
              margin
          -right: 0px;
              margin
          -bottom: 0px;
          }
          -->
          </style>
          <link href="images/css.css" rel="stylesheet" type="text/css">
          <style type="text/css">
          <!--
          .style1 {font-size: 13px}
          .style3 {color: #0066CC}
          .style4 {color: #FF0000}
          -->
          </style>
          </head>

          <body>
          <table width="60%" border="0" align="center" cellpadding="0" cellspacing="0">
            
          <tr>
              
          <td height="10" valign="bottom"><hr width="100%" size="10" color="#3399FF">test</td>
            
          </tr> 
          </table>
          </body>
          </html>

          END_OF_BODY

          sendmail(
          %mail|| print "Error: $Mail::Sendmail::error\n";
          sleep($delay); 
          }
          close(FILE);


          list file 內容格式:
          xx@163.com,xdf.com,xxx,xxx

          posted on 2008-10-17 09:33 lqx 閱讀(381) 評論(0)  編輯  收藏 所屬分類: linux

          主站蜘蛛池模板: 漳浦县| 静海县| 德江县| 济宁市| 藁城市| 武定县| 容城县| 泽库县| 从江县| 金沙县| 内乡县| 广丰县| 佛教| 丹寨县| 鸡东县| 工布江达县| 鹿邑县| 扎兰屯市| 曲水县| 云和县| 三门峡市| 吴忠市| 屯门区| 吴桥县| 镇赉县| 柘荣县| 闽侯县| 东方市| 临湘市| 上林县| 平度市| 大田县| 逊克县| 双牌县| 东丰县| 西城区| 贡觉县| 苍南县| 天津市| 嵩明县| 曲阳县|