summaryrefslogtreecommitdiffstats
path: root/util/filtermail.pl
diff options
context:
space:
mode:
Diffstat (limited to 'util/filtermail.pl')
-rw-r--r--util/filtermail.pl43
1 files changed, 43 insertions, 0 deletions
diff --git a/util/filtermail.pl b/util/filtermail.pl
new file mode 100644
index 00000000..45c13c86
--- /dev/null
+++ b/util/filtermail.pl
@@ -0,0 +1,43 @@
+#!/usr/bin/perl
+if( -e '/usr/bin/mktemp' ){
+ $fn = `/usr/bin/mktemp -q /tmp/filtermail.XXXXXXXX`;
+}
+else{
+ $fn = `/bin/mktemp -q /tmp/filtermail.XXXXXXXX`;
+}
+chomp $fn;
+
+$bbsuid = $ARGV[0];
+undef @ARGV;
+
+open FH, ">$fn";
+$norelay = 0;
+while( <> ){
+ print FH $_;
+# if( ($bbsuid) = $_ =~ /for \<(\w+)\.bbs\@ptt/ ){
+# }
+ if( /^Content-Type:/i ){
+ $norelay = 1 if( (/multipart/i && !/report/i) || /html/ );
+ last;
+ }
+}
+while( <> ){
+ print FH $_;
+}
+close FH;
+
+if( !$norelay ){
+ open FH, "<$fn";
+ open OUT, "|/home/bbs/bin/realbbsmail $bbsuid";
+ while( <FH> ){
+ print OUT $_;
+ }
+ close FH;
+ close OUT;
+ unlink $fn;
+}
+else{
+ $to = substr($fn, rindex($fn, '/') + 1);
+ `/bin/mv $fn /tmp/norelay/$to`;
+}
+