FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum Development » Plugins and Code Hacks » simple mail wrapper for qmail+mailman+fudforum
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
simple mail wrapper for qmail+mailman+fudforum [message #21992] Fri, 07 January 2005 02:56 Go to next message
mikelcu is currently offline  mikelcu   United States
Messages: 7
Registered: January 2005
Location: Portland, OR
Karma: 0
Junior Member
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: Fri, 07 January 2005 02: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 20:35 Go to previous messageGo to next message
duncanshannon is currently offline  duncanshannon   United States
Messages: 6
Registered: February 2005
Karma: 0
Junior Member
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
Re: simple mail wrapper for qmail+mailman+fudforum [message #22409 is a reply to message #22408] Tue, 01 February 2005 20:40 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
If you enable back to mailing list syncronization forum posts by members who are on the mailing list will be synched back to the list.

FUDforum Core Developer
Re: simple mail wrapper for qmail+mailman+fudforum [message #22410 is a reply to message #22409] Tue, 01 February 2005 20:45 Go to previous messageGo to next message
duncanshannon is currently offline  duncanshannon   United States
Messages: 6
Registered: February 2005
Karma: 0
Junior Member
hrm, interesting.

Im also reading this thread:

http://fudforum.org/forum/index.php?t=msg&th=3080&start=0&

re: popfud.php etc.

Sounds like I just need to jump in and get my hands dirty and then ask more questions.

Either way, im excited about FUDforum, i remember first thinking about using it for a company i worked for back in 2000.

Thanks,
duncan
Re: simple mail wrapper for qmail+mailman+fudforum [message #26011 is a reply to message #22410] Thu, 30 June 2005 02:53 Go to previous message
Tobias Eigen is currently offline  Tobias Eigen   United States
Messages: 85
Registered: June 2003
Location: Seattle, WA USA
Karma: 0
Member
Hi,

Thought I might share my experience here.. I use the private_external_archiver line in mailman's config to send the message to FUD when messages are archived. Sends to both mhonarc and FUD and works flawlessly. Here's the line:

PRIVATE_EXTERNAL_ARCHIVER = 'cat > /tmp/mailman_pvt_arc; /usr/bin/mhonarc -add -outdir /usr/local/mailman/archives/private/%(listname)s -rcfile
/usr/local/mailman/archives/private/mhonarc.rc -htmlext html -idxfname index.html -title  %(listname)s -reverse -spammode < /tmp/mailman_pvt_arc;
/home/httpd/vhosts/kabissa.org/httpdocs/forum/data/scripts/maillist.php \"%(listname)s(at)lists(dot)kabissa(dot)org\" < /tmp/mailman_pvt_arc; rm /tmp/mailman_pvt_arc'


I like the script you wrote but it does have the problem that it immediately sends the message out to Fud without first going through Mailman.

Cheers,

Tobias


Kabissa - Space for change in Africa
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Protector Scrit - use FUDForum as Central Login Manager
Next Topic: FUD, Gallery, and Netjuke
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 03:40:04 GMT 2024

Total time taken to generate the page: 0.02878 seconds