simple mail wrapper for qmail+mailman+fudforum [message #21992] |
Thu, 06 January 2005 21:56  |
mikelcu
 Messages: 7 Registered: January 2005 Location: Portland, OR
Karma: 0
|
Junior Member |
add to buddy list ignore all messages by this user
|
|
This is a super-simple wrapper script I am using to pipe mail incoming to mailing lists to both mailman and fudforum. The benefit here is that it eliminates have to actually receive mail on any account for the forum. Mail is diverted to both mailman and fudforum when it is delivered to mailman.
Prerequisites:
Mailman up and running using qmail, using the qmail-to-mailman.py script distributed with mailman. This will NOT work using .qmail aliases. see http://list.org/mailman-install/qmail-issues.html for info on setting up mailman with qmail.
Mailman must be on the same server as FUD
The Mail::Internet perl module.
Install:
Modify .qmail-default in the Mailman home directory like this:
|preline /path/to/mailwrapper.pl
Modify mailwrapper.pl to suit your setup.
What the script does:
With mailman set up properly, all mail to your list domain, i.e. lists.domain.com, will go to the mailman user. instead of piping mail directly to the qmail-to-mailman.py script, this wrapper reads in the mail, writes it to a tempfile and parses the header.
The tempfile is cat'd out to qmail-to-mailman.py and then to maillist.php with the contents of the "To" field as the argument to maillist.php.
Disclaimer:
This script works well for me, but it may not suit your needs. It is also incredibly simplistic. It does almost no error checking and it does not provide any safety nets. Do NOT try to use this if you do not know what you are doing. Incorrect use of this script can lead to mail loss No guaratees, etc. etc. Use at your own risk. Enjoy
mailwrapper.pl:
#!/path/to/perl -w
use strict;
use File::Temp qw/ tempfile tempdir /;
use Mail::Internet;
File::Temp->safe_level( File::Temp::HIGH );
my $debug = 0;
my $dir = tempdir( CLEANUP => 1 );
my ($fh, $filename) = tempfile( DIR => $dir, SUFFIX => '.ml' );
my $rmail;
my $out;
# read in the mail
while (<>)
{
$rmail .= $_;
}
# dump mail into the tempfile
print $fh $rmail;
my $head = Mail::Header->new( [ split /\n/, $rmail ] );
# our list name
my $list = $head->get("To");
# "debug" output file
open(DEB, '>>/tmp/mailwrapperdebug') unless $debug == 0;
# almost impossible for a mail to be less than 100 bytes by the time it gets here
if(length($rmail) > 100)
{
# CHANGE PATHS IN THESE NEXT 2 LINES
$out = `cat $filename | /path/to/python /path/to/qmail-to-mailman.py`;
$out .= `cat $filename | /path/to/php /path/to/maillist.php $list`;
}
else
{
$out = "ERR: received mail is only " . length($rmail) . " bytes long";
}
print DEB $out unless $debug == 0;
[Updated on: Thu, 06 January 2005 21:57] Report message to a moderator
|
|
|
Re: simple mail wrapper for qmail+mailman+fudforum [message #22408 is a reply to message #21992] |
Tue, 01 February 2005 15:35   |
|
Holy Crap!
If this is what I think it is, fantastic.
I've been searching the 'net on and off for about a week, looking for something that will keep me from having to make the decision if i should build my community around a mailing list or a forum.
From what I read, this will allow people to subscribe to a Mailman mailing list, and your script will also pipe the messages to FUDforum, each thread in the mailing list being a topic in the forum. Is that accurate?
Will there ever be a way to post in the forum, and have that go to the mailing list?
thanks for the great work.
duncan
|
|
|
|
|
|