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

          主站蜘蛛池模板: 同江市| 卢龙县| 故城县| 富裕县| 通渭县| 祁门县| 探索| 勃利县| 辽源市| 靖宇县| 丰镇市| 新巴尔虎左旗| 丽江市| 榆中县| 彝良县| 威海市| 德清县| 平远县| 门头沟区| 奎屯市| 梅州市| 卢湾区| 都江堰市| 洞头县| 济源市| 托里县| 五河县| 新宁县| 泽库县| 文化| 沛县| 南城县| 大冶市| 合川市| 津南区| 黔东| 吴忠市| 汉阴县| 凌云县| 威海市| 广饶县|