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 閱讀(383) 評論(0)  編輯  收藏 所屬分類: linux

          主站蜘蛛池模板: 乐都县| 隆安县| 东乡族自治县| 海阳市| 蓬莱市| 嵊州市| 钟山县| 景东| 文水县| 江都市| 治县。| 祥云县| 西贡区| 沁水县| 宁国市| 中江县| 伊川县| 淮南市| 河北区| 宜兰县| 波密县| 稻城县| 竹山县| 新密市| 伊金霍洛旗| 曲周县| 洪湖市| 邯郸市| 湘乡市| 浑源县| 贵阳市| 奉化市| 神木县| 北辰区| 宜黄县| 柳江县| 文山县| 左贡县| 邢台县| 大同县| 新巴尔虎左旗|