文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>一个用perl写的在linux下发送邮件的脚本

一个用perl写的在linux下发送邮件的脚本

时间:2007-08-15  来源:gavinx

这个脚本要依赖于sendmail和uuencode, 不过linux默认已经安装上这两个程序了。 怎么样使用?   ./sndemail <touser> <fromuser> <subject> <mailfile> <attachment> 邮件内容可以写成一文本文件
 

#!/usr/bin/perl


if ( $#ARGV < 0)

{
    print "Usage: mailattach.pl <touser> <fromuser> <subject> <mailfile> <file>","\n";
    exit(0);
}

$touser = $ARGV[0];
$fromuser = $ARGV[1];
$subject = $ARGV[2];
$file = $ARGV[4];

print $file;

open(MAILFILE, "$ARGV[3]") || die "can not open mail file" ;
@mailcont = <MAILFILE>;
close(MAILFILE);

$yourmail = "$touser\@alcatel-lucent.com";

open(MAIL, "|/usr/lib/sendmail -t $yourmail") || return 0;
select (MAIL);
print << "EOF";
To: $touser\@alcatel-lucent.com
From: $fromuser\@alcatel-lucent.com
Subject: $subject

@mailcont

EOF

if ( $file ne "" )
{
# File to send to user

open(FILE, "uuencode $file $file |") or die;
while( <FILE>) { print MAIL; };
close(FILE);
}
#and finish sending the mail

close(MAIL);

相关阅读 更多 +
排行榜 更多 +
鸡生化精英安卓版

鸡生化精英安卓版

飞行射击 下载
光头火柴人安卓版

光头火柴人安卓版

飞行射击 下载
轨道射击安卓版

轨道射击安卓版

飞行射击 下载