出 处: 210.32.151.169
【 以下文字转载自 UNIX_PALACE 讨论区 】 【 原文由 fuse 所发表 】
很土的办法,但是还挺好用,试运行3天了:-)
这是把mailing list转到bbs上的看板上的方法。 在bbs上看文章可以a, ?, /查找文章,可以用m, g标识 可以收录精华区,比在mail信箱里看舒服多了,最重要 的,可以一个人定阅,供众多人阅读:-)
1. 开个uid=bbs(9999)的帐号,如bsdqna 2. 在freebsd的home下面放一.forward文件, 内书: "| /home/bsdqna/mailpost /home/bbs" 3. bbs上开一版,比如:FreeBSD_Question版 4. 在/home/bsdqna/目录下放一叫mailpost文件 内容附后,chmod +x mailpost 5. cp ~/bbsadm/innbbsd/innd ~/bbsadm/innbbsd/maillist cd ~/bbsadm/innbbsd/maillist/; vi bbspost.c 找以下片断,在post_article()里 gets( userid ); gets( subject ); gets( realfrom ); --->加进这一行
if( usermail ) { // check_userec( &record, userid ); -->comment掉这行 } 再make bbspost 将生成的bbspost放到/home/bbs/innd下面
6. 然后以[email protected]发信给[email protected] subscribe freebsd_questions 再以bsdqna回信auth一下,你的小站就会源源不断有信进来乐: > 35 ◆ FreeBSD_Bugs [系统] ○ FreeBSD_Bugs 诚徵板主中 70 ◆ FreeBSD_Hacker [系统] ○ FreeBSD_Hacker 诚徵板主中 371 ◆ FreeBSD_Question [系统] ○ FreeBSD_Question 诚徵板主中
mailpost附后, 压根不懂perl的我是拿bbs自带的程序改的,一定 有更好的办法,还请各位大侠出手改进。
#!/usr/bin/perl # # mailpost ($bbshome) = @ARGV; if( ! $bbshome ) { print "Usage: mailpost bbs_home < article_from_user_mail\n"; exit( 0 ); }
$tmpfile = "/tmp/mailpost.$$"; $logfile = "$bbshome/bbslog"; # $mailbox = "$bbshome/mailbox"; $inndhome = "$bbshome/innd"; $poster = "$inndhome/bbspost"; $parsedate = "$inndhome/parsedate"; $denyfile = "$inndhome/email.deny"; $INC[ @INC ] = "$inndhome";
&mail_article();
sub logit { if( $logfile ) { open( FN, ">> $logfile" ); print FN @_; close( FN ); } else { print @_; } }
sub log_tmpfile { open( FN, $tmpfile ); $result = <FN>; close( FN ); unlink( $tmpfile ); &logit( $result ); }
sub junk_mail { local ($msg) = @_;
&logit( "unknown mail $msg\n" ); if( ! $name ) { $name = "Mail-Daemon"; } if( ! $subject ) { $subject = "<Unknown>: $msg"; } open( FN, "| $poster post $bbshome/boards/junk > $tmpfile" ); print FN "$name\n"; print FN "$subject\n"; print FN @MAIL; close( FN ); &log_tmpfile(); exit( 0 ); }
sub uudecode { local ($begin) = @_;
$line = $MAIL[ $begin + 1 ]; if( substr( $line, 0, 1 ) ne "M" ) { return; } $tmpfile = "/tmp/decode.$$"; open( FN, "| /bin/uudecode" ); print FN "begin 644 $tmpfile\n"; foreach $n ($begin + 1 .. $#MAIL) { print FN $MAIL[ $n ]; } close( FN ); $#MAIL = $begin - 1; open( FN, $tmpfile ); while( <FN> ) { $MAIL[ @MAIL ] = $_; } close( FN ); unlink( $tmpfile ); }
sub decode_mail { foreach $n (0 .. $#MAIL) { $line = $MAIL[ $n ]; if( substr( $line, 0, 6 ) eq "begin " ) { if( $line =~ /^begin \d+ \w/ ) { &uudecode( $n ); return; } } } }
sub parse_header { $header = 1; $line = 0; while( !( $subject ) ) { if( $line > $#MAIL ) { &junk_mail( "from $realfrom" ); } $_ = $MAIL[ $line++ ]; chop; if( $_ eq "" ) { $header = ""; } if( $header ) { if( index( $_, "From: " ) == 0 ) { $from = substr( $_, 6, 99 ); ($name) = split( "<", $from ); } elsif( index( $_, "Subject: " ) == 0 ) { $subject = substr( $_, 9, 99 ); } } } # $name = $from; $name = $from unless $name; $name = $realfrom unless $name; $line = 0; # if( $header ) { while( $line <= $#MAIL && $MAIL[ $line ] ne "\n" ) { $line++; }
$MAILBODY = $line # } }
sub mail_article { chdir( $bbshome ); @MAIL = <STDIN>; if( $mailbox ) { open( FN, ">> $mailbox" ); print FN @MAIL; close( FN ); } if( $MAIL[ 0 ] =~ /^From (\S+) / ) { $realfrom = $1; } else { &junk_mail( "format (without From)" ); } if( -f $denyfile ) { open( FN, $denyfile ); while( <FN> ) { ($deny) = split( /\s+/, $_ ); if( $realfrom eq $deny ) { &junk_mail( "Denyaddr $realfrom" ); } } close( FN ); } &decode_mail(); &parse_header(); $boardpath = "$bbshome/boards/test"; if( ! -d $boardpath ) { &junk_mail( "board `$board' from $realfrom." ); } else { # $title =~ s/^[/^[/g; $title = $subject; open( FN, "| $poster mail $bbshome/boards/FreeBSD_Question > $tmpfile" ); print FN "$name\n"; print FN "$title\n"; print FN "$realfrom\n"; print FN "$from\n"; print FN "邮件作者: $from\n"; print FN "邮件来源: $realfrom\n"; for ($n= $MAILBODY; $n <= $#MAIL; $n++) { print FN $MAIL[$n]; }
close( FN ); &log_tmpfile(); } }
-- ※ 来源:.笑书亭 bbs.zju.ml.org.[FROM: 210.32.151.168] -- ※ 转载:.笑书亭 bbs.zju.ml.org.[FROM: 210.32.151.168]
|
|