| 订阅 | 在线投稿
分享
 
 
当前位置: 王朝网络 >> perl >> Mailing List ( you jian lie biao ) yuan li jian shu ji wo de perl shi xian

Mailing List ( you jian lie biao ) yuan li jian shu ji wo de perl shi xian

2008-05-31 00:03:24 编辑來源:互联网 评论
 
 
 
本文为【Mailing List (邮件列表)原理简述及我的perl实现】的拼音翻译版
  zhu : ben wen ben lai shi yi zao yao xie de , ke shi cheng xu xie le you duan shi jian le , zui jin yi duan shi jian you hen mang , ju ran gei wang le , xian zai bu shang 。
  zheng wen
  da bu fen IT ren yuan dou shi yong guo you jian lie biao , huo zhe lei si de fu wu , dan you jian lie biao de nei bu gong zuo yuan li ze bu shi jian dan de ding yue , tui ding yue na me jian dan 。 zui jin gen ju zi ji de yi xie ren shi , yong perl shi xian le yi ge fei chang jian dan de MLM cheng xu , ye shun bian tan tan you jian lie biao de zui ji ben gong zuo yuan li 。
  you jian lie biao , jian dan de lai shuo , jiu shi ren yi lie biao cheng yuan xiang gai lie biao fa de you jian , qi ta suo you ren ( ke yi bao kuo ta zi ji ) dou neng shou dao , bing qie mei ge ren neng zi you ding yue 、 tui ding 。 geng feng fu de you jian lie biao huan bao kuo le zhai yao , jing que quan xian guan li ,web archive gong neng deng deng 。
  zhu ming de kai yuan you jian lie biao ruan jian ru mailman, majodomo, ezmlm, sympa, ecartis deng dou shi gong neng wan bei de you jian lie biao ruan jian , dan gui gen jie di , zui jian dan de you jian lie biao zhi shao ying gai bao han ru xia gong neng :
  ding yue gong neng , ji yong hu fa te ding ding yue xin jian dao you jian lie biao que ren ding yue gong neng , ji yong hu bi xu gei MLM fa que ren xin cai neng zheng shi ding yue tui ding gong neng , yong hu ke zi you tui chu ding yue fu wu 。 ren yi lie biao cheng yuan gei you jian lie biao fa de you jian , qi ta ren dou ying shou dao 。 yao shi xian shang shu de gong neng , ru guo shi yong perl de hua bing bu fu duo , pei he Postfix MTA ke yi fei chang fang bian de kai fa chu jian yi de you jian lie biao ruan jian 。 yi xia shi zi ji kai fa de MMList(Mini Mailing List) de ji ben jie gou :
Mailing List (邮件列表)原理简述及我的perl实现

  pei zhi ji yu Postfix, shi yong alias de fang fa , jiang you jian tong guo guan dao song dao MMList: main.cf li xu yao pei zhi de nei rong :
  alias_maps = hash:/etc/postfix/aliases hash:/etc/postfix/mml.aliasesvirtual_alias_maps = hash:/etc/postfix/mml.virtual_alias_maps
  mml.aliases de nei rong :
  # alias filetest-subscribe-hzqbbc.com: "|/usr/bin/mml -cmd=subscribe -list=test@hzqbbc.com"test-confirm-hzqbbc.com: "|/usr/bin/mml -cmd=confirm -list=test@hzqbbc.com"test-unsubscribe-hzqbbc.com: "|/usr/bin/mml -cmd=unsubscribe -list=test@hzqbbc.com"
  mml.virtual_alias_maps de nei rong :
  test-subscribe@hzqbbc.com test-subscribe-hzqbbc.comtest-confirm@hzqbbc.com test-confirm-hzqbbc.comtest-unsubscribe@hzqbbc.com test-unsubscribe-hzqbbc.com
  MMList de perl shi xian #!/usr/bin/perl -w# vim: set cindent expandtab ts=4 sw=4:# MMList - a very lightweight MLM software## Author: He zhiqiang # CopyRight (c) 1998-2005 hzqbbc.com## License: GPL v2use strict;use Getopt::Long;use vars qw(%cfg $cmd $list @KEY_MAP);use vars qw($user $subj $SLOG);$user = $subj = "";@KEY_MAP = ( 0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E', 'F','G','H','I','J','K','L','M','N','O', 'P','Q','R','S','T','U','V','W','X','Y', 'Z','a','b','c','d','e','f','g','h','i', 'j','k','l','m','n','o','p','q','r','s', 't','u','v','w','x','y','z');# PRoto-type:# cmd == indicate the 'subscribe' or 'unsubscribe'# list == indicate the list namemy $res = GetOptions("cmd=s" = \$cmd, "list=s" = \$list);$cfg{'basedir'} = "/var/lib/mmlist";$cfg{'listdir'} = $cfg{'basedir'}."/lists";$cfg{'hostname'} = "list.hzqbbc.com";open (MLOG, " $cfg{'basedir'}/mail.log");open ($SLOG, " $cfg{'basedir'}/base.log");# read from STDINwhile() { print MLOG $_; if(/^From: (.*)$/) { chomp; m/([a-zA-Z0-9-_=\.]+\@[a-zA-Z0-9-_=\.]+)/; if($1) { $user = lc $1; } }elsif(/^Subject: (.*)$/) { chomp; $subj = $1; $subj =~ s/\s//g; }}syslog("cmd = $cmd");if($cmd eq "subscribe") { if(user_exist($user)) { syslog("$user subscribed"); my $body = q(Hey guy, you have already subscribed!); sendmail($user, "Subscribe failure", $body); }else { my $sid = gen_sid(); open(FD, " $cfg{'listdir'}/$list/queue/$user") or syslog("$!") and die "Can't write to $user, $!\n"; printf FD "%s\:%s\n", time, $sid; close FD; syslog("confirm $user"); my $body = "Hey guy, reply to me with the code $sid \n" ."in the subject section\n"; $list =~ m/([^:]+)\@(.*)/; my $from = "$1-confirm\@$2"; sendmail($user, "Confirm subscribe", $body, $from); }}elsif($cmd eq "confirm") { if(not user_exist($user)) { syslog("$user not exist"); if(valid_sid($user, $subj)) { syslog("added $user"); add_user($user); my $body = "Welcome to $list :-)\n"; sendmail($user, "Added to the list", $body); }else { syslog("fail to confirm $user"); my $body = "Hey guy, your confirm fail, please try again\n"; sendmail($user, "Confirm failure", $body); } }else { my $body = "Hey guy, you step into a wrong situation!\n"; sendmail($user, "Wrong action", $body); }}elsif($cmd eq "unsubscribe") { if(user_exist($user)) { syslog("$user removed"); del_user($user); my $body = "Hey guy, you have been removed from the $list\n"; sendmail($user, "Goodbye - from $list", $body); }else { my $body = "Hey guy, you step into a wrong situation!\n"; sendmail($user, "Wrong action", $body); }}else { print STDERR "m3 error cmd!\n"; exit(13);}exit(0);## funcs to handle mail listsub sendmail { my($to, $subj, $body, $from) = @_; if(not defined $from) { $from = "m3\@$cfg{'hostname'}"; } open(CMD, "| /usr/sbin/sendmail -oi -t -f \"$from\" $to") or die "Can't exec /usr/sbin/sendmail, $!\n"; print CMD close CMD;}sub user_exist { my $user = shift; if (! -r "$cfg{'listdir'}/$list/users.txt") { return 0; } open(FD, "or die "Can't open $list, $!\n"; while() { chomp; if(/^$user$/i) { return 1; } } close FD; 0;}# gen_sid - to generate unique session idsub gen_sid { my ($sid, $len) = ("", $_[0] ? $_[0]-1 : 23); srand(time()); foreach(0...$len) { $sid .= $KEY_MAP[int rand(61)]; # total of $#KEY_MAP -1 } $sid;}sub valid_sid { my ($user, $sid) = @_; open(FD, "or syslog("can't open $user, $!") and die "Can't open $user, $!\n"; $_ = ; chomp; ($_) = m/[^:]+:(.*)/; if($sid eq $_) { syslog("auth ok for $user"); return 1; } close FD; return 0;}sub add_user { my ($user) = @_; unlink "$cfg{'listdir'}/$list/queue/$user"; # clean up user cookie/queue open(FD, " $cfg{'listdir'}/$list/users.txt") or die "Can't append to users.txt for $list, $!\n"; print FD $user, "\n"; close FD;}sub del_user { my ($user) = @_; my $buf = undef; open(FD, "or die "Can't open users.txt for $list, $!\n"; while() { chomp; if(!/^$user$/) { $buf.="$_\n"; } } close FD; open(FD, " $cfg{'listdir'}/$list/users.txt") or die "Can't write to users.txt for $list, $!\n"; print FD $buf; close FD;}sub syslog { my ($msg) = @_; chomp $msg; printf $SLOG "%s $msg\n", time;}【原文】【汉音对照
 
 
 
 
 
 
 
 
 
日版宠物情人插曲《Winding Road》歌词

日版宠物情人2017的插曲,很带节奏感,日语的,女生唱的。 最后听见是在第8集的时候女主手割伤了,然后男主用嘴帮她吸了一下,插曲就出来了。 歌手:Def...

兄弟共妻,我成了他们夜里的美食

老钟家的两个儿子很特别,就是跟其他的人不太一样,魔一般的执着。兄弟俩都到了要结婚的年龄了,不管自家老爹怎么磨破嘴皮子,兄弟俩说不娶就不娶,老父母为兄弟两操碎了心...

如何磨出破洞牛仔裤?牛仔裤怎么剪破洞?

把牛仔裤磨出有线的破洞 1、具体工具就是磨脚石,下面垫一个硬物,然后用磨脚石一直磨一直磨,到把那块磨薄了,用手撕开就好了。出来的洞啊很自然的。需要猫须的话调几...

我就是扫描下图得到了敬业福和爱国福

先来看下敬业福和爱国福 今年春节,支付宝再次推出了“五福红包”活动,表示要“把欠大家的敬业福都还给大家”。 今天该活动正式启动,和去年一样,需要收集“五福”...

冰箱异味产生的原因和臭味去除的方法

有时候我们打开冰箱就会闻到一股异味,冰箱里的这种异味是因为一些物质发出的气味的混合体,闻起来让人恶心。 产生这些异味的主要原因有以下几点。 1、很多人有这种习...

 
 
zhu : ben wen ben lai shi yi zao yao xie de , ke shi cheng xu xie le you duan shi jian le , zui jin yi duan shi jian you hen mang , ju ran gei wang le , xian zai bu shang 。 zheng wen da bu fen IT ren yuan dou shi yong guo you jian lie biao , huo zhe lei si de fu wu , dan you jian lie biao de nei bu gong zuo yuan li ze bu shi jian dan de ding yue , tui ding yue na me jian dan 。 zui jin gen ju zi ji de yi xie ren shi , yong perl shi xian le yi ge fei chang jian dan de MLM cheng xu , ye shun bian tan tan you jian lie biao de zui ji ben gong zuo yuan li 。 you jian lie biao , jian dan de lai shuo , jiu shi ren yi lie biao cheng yuan xiang gai lie biao fa de you jian , qi ta suo you ren ( ke yi bao kuo ta zi ji ) dou neng shou dao , bing qie mei ge ren neng zi you ding yue 、 tui ding 。 geng feng fu de you jian lie biao huan bao kuo le zhai yao , jing que quan xian guan li ,web archive gong neng deng deng 。 zhu ming de kai yuan you jian lie biao ruan jian ru mailman, majodomo, ezmlm, sympa, ecartis deng dou shi gong neng wan bei de you jian lie biao ruan jian , dan gui gen jie di , zui jian dan de you jian lie biao zhi shao ying gai bao han ru xia gong neng : ding yue gong neng , ji yong hu fa te ding ding yue xin jian dao you jian lie biao que ren ding yue gong neng , ji yong hu bi xu gei MLM fa que ren xin cai neng zheng shi ding yue tui ding gong neng , yong hu ke zi you tui chu ding yue fu wu 。 ren yi lie biao cheng yuan gei you jian lie biao fa de you jian , qi ta ren dou ying shou dao 。 yao shi xian shang shu de gong neng , ru guo shi yong perl de hua bing bu fu duo , pei he Postfix MTA ke yi fei chang fang bian de kai fa chu jian yi de you jian lie biao ruan jian 。 yi xia shi zi ji kai fa de MMList(Mini Mailing List) de ji ben jie gou : [url=http://www.wangchao.net.cn/bbs/pydetail_1734636.html][img]http://image.wangchao.net.cn/it/1323601190928.gif[/img][/url] pei zhi ji yu Postfix, shi yong alias de fang fa , jiang you jian tong guo guan dao song dao MMList: main.cf li xu yao pei zhi de nei rong : alias_maps = hash:/etc/postfix/aliases hash:/etc/postfix/mml.aliasesvirtual_alias_maps = hash:/etc/postfix/mml.virtual_alias_maps mml.aliases de nei rong : # alias filetest-subscribe-hzqbbc.com: "|/usr/bin/mml -cmd=subscribe -list=test@hzqbbc.com"test-confirm-hzqbbc.com: "|/usr/bin/mml -cmd=confirm -list=test@hzqbbc.com"test-unsubscribe-hzqbbc.com: "|/usr/bin/mml -cmd=unsubscribe -list=test@hzqbbc.com" mml.virtual_alias_maps de nei rong : test-subscribe@hzqbbc.com test-subscribe-hzqbbc.comtest-confirm@hzqbbc.com test-confirm-hzqbbc.comtest-unsubscribe@hzqbbc.com test-unsubscribe-hzqbbc.com MMList de perl shi xian #!/usr/bin/perl -w# vim: set cindent expandtab ts=4 sw=4:# MMList - a very lightweight MLM software## Author: He zhiqiang # CopyRight (c) 1998-2005 hzqbbc.com## License: GPL v2use strict;use Getopt::Long;use vars qw(%cfg $cmd $list @KEY_MAP);use vars qw($user $subj $SLOG);$user = $subj = "";@KEY_MAP = ( 0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E', 'F','G','H','I','J','K','L','M','N','O', 'P','Q','R','S','T','U','V','W','X','Y', 'Z','a','b','c','d','e','f','g','h','i', 'j','k','l','m','n','o','p','q','r','s', 't','u','v','w','x','y','z');# PRoto-type:# cmd == indicate the 'subscribe' or 'unsubscribe'# list == indicate the list namemy $res = GetOptions( "cmd=s" = \$cmd, "list=s" = \$list);$cfg{'basedir'} = "/var/lib/mmlist";$cfg{'listdir'} = $cfg{'basedir'}."/lists";$cfg{'hostname'} = "list.hzqbbc.com";open (MLOG, " $cfg{'basedir'}/mail.log");open ($SLOG, " $cfg{'basedir'}/base.log");# read from STDINwhile() { print MLOG $_; if(/^From: (.*)$/) { chomp; m/([a-zA-Z0-9-_=\.]+\@[a-zA-Z0-9-_=\.]+)/; if($1) { $user = lc $1; } }elsif(/^Subject: (.*)$/) { chomp; $subj = $1; $subj =~ s/\s//g; }}syslog("cmd = $cmd");if($cmd eq "subscribe") { if(user_exist($user)) { syslog("$user subscribed"); my $body = q(Hey guy, you have already subscribed!); sendmail($user, "Subscribe failure", $body); }else { my $sid = gen_sid(); open(FD, " $cfg{'listdir'}/$list/queue/$user") or syslog("$!") and die "Can't write to $user, $!\n"; printf FD "%s\:%s\n", time, $sid; close FD; syslog("confirm $user"); my $body = "Hey guy, reply to me with the code $sid \n" ."in the subject section\n"; $list =~ m/([^:]+)\@(.*)/; my $from = "$1-confirm\@$2"; sendmail($user, "Confirm subscribe", $body, $from); }}elsif($cmd eq "confirm") { if(not user_exist($user)) { syslog("$user not exist"); if(valid_sid($user, $subj)) { syslog("added $user"); add_user($user); my $body = "Welcome to $list :-)\n"; sendmail($user, "Added to the list", $body); }else { syslog("fail to confirm $user"); my $body = "Hey guy, your confirm fail, please try again\n"; sendmail($user, "Confirm failure", $body); } }else { my $body = "Hey guy, you step into a wrong situation!\n"; sendmail($user, "Wrong action", $body); }}elsif($cmd eq "unsubscribe") { if(user_exist($user)) { syslog("$user removed"); del_user($user); my $body = "Hey guy, you have been removed from the $list\n"; sendmail($user, "Goodbye - from $list", $body); }else { my $body = "Hey guy, you step into a wrong situation!\n"; sendmail($user, "Wrong action", $body); }}else { print STDERR "m3 error cmd!\n"; exit(13);}exit(0);## funcs to handle mail listsub sendmail { my($to, $subj, $body, $from) = @_; if(not defined $from) { $from = "m3\@$cfg{'hostname'}"; } open(CMD, "| /usr/sbin/sendmail -oi -t -f \"$from\" $to") or die "Can't exec /usr/sbin/sendmail, $!\n"; print CMD close CMD;}sub user_exist { my $user = shift; if (! -r "$cfg{'listdir'}/$list/users.txt") { return 0; } open(FD, "or die "Can't open $list, $!\n"; while() { chomp; if(/^$user$/i) { return 1; } } close FD; 0;}# gen_sid - to generate unique session idsub gen_sid { my ($sid, $len) = ("", $_[0] ? $_[0]-1 : 23); srand(time()); foreach(0...$len) { $sid .= $KEY_MAP[int rand(61)]; # total of $#KEY_MAP -1 } $sid;}sub valid_sid { my ($user, $sid) = @_; open(FD, "or syslog("can't open $user, $!") and die "Can't open $user, $!\n"; $_ = ; chomp; ($_) = m/[^:]+:(.*)/; if($sid eq $_) { syslog("auth ok for $user"); return 1; } close FD; return 0;}sub add_user { my ($user) = @_; unlink "$cfg{'listdir'}/$list/queue/$user"; # clean up user cookie/queue open(FD, " $cfg{'listdir'}/$list/users.txt") or die "Can't append to users.txt for $list, $!\n"; print FD $user, "\n"; close FD;}sub del_user { my ($user) = @_; my $buf = undef; open(FD, "or die "Can't open users.txt for $list, $!\n"; while() { chomp; if(!/^$user$/) { $buf.="$_\n"; } } close FD; open(FD, " $cfg{'listdir'}/$list/users.txt") or die "Can't write to users.txt for $list, $!\n"; print FD $buf; close FD;}sub syslog { my ($msg) = @_; chomp $msg; printf $SLOG "%s $msg\n", time;}
󰈣󰈤
  免责声明:本文仅代表作者个人观点,与王朝网络无关。王朝网络登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
可爱小魔女
夏日小桃红
琦吖囡半熟乖巧清新写真
天使的微笑
痞子的甘南日记
疑是银河落九天
雪域坝上四——纯美色
冬日恋歌——西城杨柳弄轻柔
 
>>返回首页<<
 
 
 为你推荐
 
 
 
 转载本文
 UBB代码 HTML代码
复制到剪贴板...
 
 热帖排行
 
 
 
 
 
©2005- 王朝网络 版权所有