linux 下用 perl 发email

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 
=>   ' [email protected] ' ,
    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 内容格式:
[email protected],xdf.com,xxx,xxx

你可能感兴趣的:(linux 下用 perl 发email)