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
Return to the default flat view Create a new topic Submit Reply
simple mail wrapper for qmail+mailman+fudforum [message #21992] Fri, 07 January 2005 02:56 Go to previous message
mikelcu is currently offline  mikelcu   United States
Messages: 7
Registered: January 2005
Location: Portland, OR
Karma:
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

[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
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: Thu Nov 28 03:37:39 GMT 2024

Total time taken to generate the page: 0.03931 seconds