For your site I doubt performance will really be an issue no matter what you do. My setup is a little more complex, so I've simplified somewhat. I'm not checking the messageid against the sender/recipient right now to make sure those two match up, i'm just checking the messageid's straight. Also, I invalidate the messageid after one response has come in (in case it could be pulled from webpages or something, but i really doubt this is a big issue, i've just been playing around). If you don't want to only let a single messageid whitelist an email once, simply uncomment the line of code in the second plugin.
database schema: mysql> show create table messageid; +-----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | messageid | CREATE TABLE `messageid` ( `messageid` varchar(64) NOT NULL default '', `active` tinyint(1) default '1', PRIMARY KEY (`messageid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 | +-----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ outgoing email plugin: #!/usr/bin/perl -w use DBI; sub init { my ($self, $qp, @args) = @_; $self->{dbname} = 'postfix'; $self->{dbuser} = 'postfix'; $self->{dbpass} = 'password'; } sub hook_queue { my ($self, $transaction) = @_; my $dbh = DBI->connect("DBI:mysql:".$self->{dbname}, $self->{dbuser}, $self->{dbpass}) or die("Couldn't connect to DB"); if (!$dbh) { return (DECLINED); } my $insertid = $dbh->prepare("INSERT INTO messageid (messageid) values (?)"); $insertid->execute($transaction->header->get('Message-ID')); return (DECLINED); } incoming email plugin: use DBI; sub init { my ($self, $qp, @args) = @_; $self->{dbname} = 'postfix'; $self->{dbuser} = 'postfix'; $self->{dbpass} = 'password'; } sub hook_data_post { my ($self, $transaction) = @_; if ($transaction->notes('whitelisted')) { return (DECLINED); } my $dbh = DBI->connect("DBI:mysql:".$self->{dbname}, $self->{dbuser},$self->{dbpass}) or $self->log(LOGALERT, "Couldn't connect to DB: "); my $msgid = $transaction->header->get('In-Reply-To'); if (!$msgid) { return (DECLINED); } #if you don't want to invalidate the messageid from being used again, #my $check_id = $dbh->prepare("SELECT active from messageid where messageid = ? and active = 1"); my $check_id = $dbh->prepare("UPDATE messageid set active = 0 where messageid=? and active=1"); $check_id->execute($msgid); if ($check_id->rows > 0) { $transaction->notes('whitelisted',1); } return (DECLINED); } Hope this helps Regards, Tom > Yes it is possible and better about performance ! I have a few users > 2-3 max and all on the same local network. I'm very interesting in > your proposition. So you make an association in the database between > the message id and the local user mailbox, is this right ? > > You use qpsmtpd as the outgoing mail server, add a queue pluging which > always return DECLINED and store the message id in the database with > the local user mailbox. Next use the common postfix queue plugin to > deliver the mail on the Internet network. > > I'm interesting if you have some peace of code. > > John Peacock : this solution should correct the performance problem ? > > Quoting Tom Callahan <[EMAIL PROTECTED]>: > >> If you force your users to send outgoing mail via your mailserver (via >> policy/SPF/etc), you can store it in a database on its way out, and >> then query the database as you're receiving email. I've been playing >> around with this on my system so that these responses get whitelisted >> and don't invoke spamassassin and it seems to be working pretty well. >> >> Tom >> >> [EMAIL PROTECTED] wrote: >>> Hi, >>> >>> First of all, thanks to qpsmtpd developer and contributor. It >>> really simplify my mail configuration/test about anti-spam. >>> >>> I want to develop a new plugin based on the queue/maildir plugin >>> but I have not enough (at this time) skill in perl ! >>> >>> I think this plugin should help somebody else... >>> >>> The idea : >>> >>> I have multiple maildir mailbox, I want to deliver new mail in the >>> mailbox containing the previous message (reply, thread, ...). >>> >>> more formal : >>> >>> If the new mail contain a 'Reference' or 'In-Reply-To' header then >>> search in all mailbox for the 'Reference' id and deliver the >>> message to that mailbox. >>> >>> So The user get the answer in his mailbox not in the general one ... >>> >>> I need a perl method to search recursively a file containing >>> "Reference : xxxxxxx" or "In-Reply-To : xxxxxxxxxxx" and return the >>> maildir basename. >>> >>> I need the $transaction method to get Reference or In-Reply-To in >>> the new mail. >>> >>> Everything else should be writable by myself .... >>> >>> Thanks for your help. >>> Julien. > > >