diff -pu og2list/mail-in.pl og2list.new/mail-in.pl
--- og2list/mail-in.pl	Fri Jan 12 18:49:49 2007
+++ og2list.new/mail-in.pl	Fri Jan 12 18:50:00 2007
@@ -245,6 +245,8 @@ use vars qw(
 
 	    $add_attachment_stmt $add_attachment_handle
 
+		%sites $site	
+
 	    $dbtype $dbuser $dbauth $dbhost $dbase
 	    $mail_domain
 	    $sendmail_binary @sendmail_args
@@ -333,6 +335,19 @@ $head->unfold;
   ($head->get("From",0) =~ /^\s*(.*?)\s*<(.*)>\s*$/);
 ($to_name, $to_address) =
   ($head->get("To",0) =~ /^\s*(.*)\s*<(.*)>\s*$/);
+
+# --------------------
+# Now that we know the to_address we can get the site
+# Extract the site for our database connection
+$site = $to_address;
+$site =~ /@.*\.(.*)\.com.*/;
+$site = $1;
+$mail_domain = $sites{$site}{'mail_domain'};
+$dbtype = $sites{$site}{'dbtype'};
+$dbase  = $sites{$site}{'dbase'};
+$dbhost = $sites{$site}{'dbhost'};
+$dbuser = $sites{$site}{'dbuser'};
+$dbauth = $sites{$site}{'dbauth'};
 
 # Decode subject according to RfC1522/2045, using MIME::Words
 foreach (decode_mimewords($head->get("Subject",0))) {
diff -pu og2list/mail-out.pl og2list.new/mail-out.pl
--- og2list/mail-out.pl	Fri Jan 12 18:49:49 2007
+++ og2list.new/mail-out.pl	Fri Jan 12 18:50:00 2007
@@ -78,6 +78,8 @@ use vars qw(
 
    $get_digest_rcpt_handle $clear_digest_rcpt_handle
 
+	%sites $site $key $val
+
    $dbtype $dbuser $dbauth $dbhost $dbase $mail_domain
 
    $set_reply_to
@@ -266,6 +268,18 @@ sub send_blackhole($$$$) {
 getopts('d', \%opts);
 $do_digest = $opts{'d'};
 
+# Loop through the hash sites
+while (($key, $val) = each %sites) {
+
+# Fill in database connections from site of sites hash
+$site = $key;
+$mail_domain = $sites{$site}{'mail_domain'};
+$dbtype = $sites{$site}{'dbtype'};
+$dbase  = $sites{$site}{'dbase'};
+$dbhost = $sites{$site}{'dbhost'};
+$dbuser = $sites{$site}{'dbuser'};
+$dbauth = $sites{$site}{'dbauth'};
+
 # Make database connection
 $dsn = "DBI:$dbtype:$dbase:$dbhost";
 $dbh = DBI->connect($dsn, $dbuser, $dbauth) or die;
@@ -428,7 +442,7 @@ while ( (my $mid, my $nid, my $timestamp
   $get_create_mail_handle->execute($mid, $nid, $timestamp, $uid, $nid);
   $get_del_arg_handle->execute($mid);
 }
-
+} # end of while sites
 
 # Local Variables:
 # mode:cperl
diff -pu og2list/mail.conf og2list.new/mail.conf
--- og2list/mail.conf	Fri Jan 12 18:49:49 2007
+++ og2list.new/mail.conf	Fri Jan 12 18:50:00 2007
@@ -1,20 +1,49 @@
 # -*- cperl -*-
 # $Id: mail.conf,v 1.7.2.2 2006/11/28 18:08:34 killes Exp $
 
-# The domain that is appended to the ogroup-specific localparts.
-$mail_domain = "example.invalid";
+# og2list site settings
+# Note: include as many sites as you want by creating a hash
+# for them. For each hash include it in the sites hash below.
 
-# Connection parameters to the Drupal database
-# type of database connection
-$dbtype = "mysql";
-# name of your database server
-$dbase  = "";
-# name of your Drupal database
-$dbhost = "localhost";
-# name of your database user
-$dbuser = "";
-# the user's password for your database server
-$dbauth = "";
+# hash of first site to use with og2list
+my %examplesite1 = (
+	# The domain that is appended to the ogroup-specific localparts.
+	'mail_domain' => 'lists.examplesite1.com',
+	# Connection parameters to the Drupal database
+	# type of database connection
+	'dbtype' => 'mysql',
+	# name of your database server
+	'dbase' => 'examplesite1db',
+	# name of your Drupal database
+	'dbhost' => 'localhost',
+	# name of your database user
+	'dbuser' => 'drupaluser',
+	# the user's password for your database server
+	'dbauth' => 'pass',
+);
+
+# hash of another site
+my %examplesite2 = (
+	'mail_domain' => 'lists.examplesite2.com',
+	'dbtype' => 'mysql',
+	'dbase' => 'examplesite2db',
+	'dbhost' => 'localhost',
+	'dbuser' => 'drupaluser',
+	'dbauth' => 'pass',
+);
+
+# hash storing each site
+# Note: To have a site be included with og2list it must be
+# listed in this hash. The key must match the domain name
+# of your mail domain and the value must be a hash you
+# created above.
+%sites = (
+	# key => value
+	# Note: since value is a hash you must dereference it
+	# by using a backslash (\)
+	'examplesite1' => \%examplesite1,
+	'examplesite2' => \%examplesite2,
+);
 
 # Reply-To header to the list for outgoing messages
 $set_reply_to = 0;
