Using mailman, fud, /etc/aliases, maillist.php, and custom filter scripts [message #17220] |
Fri, 19 March 2004 17:16 |
Marticus
Messages: 272 Registered: June 2002
Karma:
|
Senior Member |
add to buddy list ignore all messages by this user
|
|
I have been using FUD for some time now using /etc/aliases instead of procmail with the email gateway script maillist.php. My system is running mailman and postfix. I created the mailing list rule in Fud's administrative interface to have forum posts sent to kias-general mailing list and I created an alias as such:
fud-kias-general: "|/home/sites/kias/fudforum/data/scripts/maillist.php 1"
I added fud-kias-general to the kias-general membership with the 'not metoo' flag set to prevent looping. When a message is sent to the list, it also goes to fud-kias-general which points it to the maillist.php script which in turn posts it to the forum.
Note: in order for postfix to execute the script I had to make maillist.php executable, which by default is not.
Up until recently this had worked fine for me; however, I decided I needed more.
All of my forums get filled up with extra crap like quoted material and mailman footers.
Since I am no guru of regex, I had to resort to writing my own filter in perl using a combination of loops and keywords added to the mailman footer. Because postfix does not allow multiple pipes in /etc/aliases, e.g., fud-kias-general: "| filter.pl | maillist.php 1", I had to wrap the filter around maillist.php as such, fud-kias-general: "|filter.pl 1".
For those of you who know perl, this is a no brainer:
filter.pl:
--
#!/usr/bin/perl
use strict;
use warnings;
# Path to maillist.php
my $maillist = "/home/sites/kias/fudforum/data/scripts/maillist.php";
my $tag = "~mailing list information~"; # prepend mailman footer
my $endtag = "~~"; # append mailman footer
my $footer = 0;
# Open a pipe to maillist.php
# $ARGV[0] passes the list number 1 to maillist.php
open FUD, "|-", "$maillist $ARGV[0]" or die "Cannot open: $!";
# Pass through to maillist.php each line of the message
while (<STDIN>) {
$footer = 1 if ($_ =~ /($tag)/); # Start of mailman footer
print FUD $_ if ($footer ne 1);
$footer = 0 if ($_ =~ /($endtag)/); # End of mailman footer
}
print FUD "[mailing list footer removed]"; # added to bottom of email
close FUD; # close the pipe
--
Now I have filtered everything between and including $tag and $endtag sending a cleaner post to the forum.
I hope this helps someone else.
|
|
|