The stock qmail has no database interaction capability what so ever, none. Luckily it's split up into a lot of small parts, so it's not hard to add on to. I have seen a modified version qmail-smtpd that will access an LDAP database, but that's not quite what you want either.

I've got a simple idea, I don't think it's terribly efficient, but it should do the job. Here's what the supervise run script for my external smtp server looks like now:

[EMAIL PROTECTED]:~$ cat /service/smtp_inet/run
#!/bin/sh
PATH="/usr/local/qmail/bin:/usr/local/ucspi-tcp/bin:/usr/local/bin:$PATH"
export PATH
QMAILQUEUE=/service/smtp_inet/filter
export QMAILQUEUE
exec 2>&1 \
envuidgid qmaild \
softlimit -d250000 \
tcpserver -vUDRHl `uname -n`.`dnsdomainname` -x tcp.cdb -- 66.92.8.243 25 \
rblsmtpd -b \
-r relays.ordb.org \
-r list.dsbl.org \
-r relays.osirusoft.com \
qmail-smtpd

If the environment variable RELAYCLIENT is set when qmail-smtpd is executed, it will allow that client to send outgoing email. I purpose to insert a program between tcpserver and qmail-smtpd to modify the environment based on the database. Here's what that would look like:

[EMAIL PROTECTED]:~$ cat /service/smtp_inet/run.pbsmtp
#!/bin/sh
PATH="/usr/local/qmail/bin:/usr/local/ucspi-tcp/bin:/usr/local/bin:$PATH"
export PATH
QMAILQUEUE=/service/smtp_inet/filter
export QMAILQUEUE
exec 2>&1 \
envuidgid qmaild \
softlimit -d250000 \
tcpserver -vUDRHl `uname -n`.`dnsdomainname` -x tcp.cdb -- 66.92.8.243 25 \
rblsmtpd -b \
-r relays.ordb.org \
-r list.dsbl.org \
-r relays.osirusoft.com \
/path/to/dbmail-qmail-pbsmtp \
qmail-smtpd

Here's an example dbmail-qmail-pbsmtp that I hacked up in perl right quick. It should work, but by no means is it ready for production, I haven't even tested it!

[EMAIL PROTECTED]:~$ cat dbmail-qmail-pbsmtp
#!/usr/bin/perl -w
use strict;
use warnings;
use DBI;
# connect to the dbmail db
my $dbh = DBI->connect('db', 'user', 'passwd', {RaiseError => 1})
  or die $DBI::errstr;
# tcpserver passes in the remote IP via the environment.
# this select statement assumes a table named 'pbsmtp'
# with a single column 'ip' containing all the valid IPs
# which are allowed to relay, in dotted decimal format
my($pbsmtp, @junk) = $dbh->selectrow_array(
  "select count(*) from pbsmtp where ip  = '$ENV{TCPREMOTEIP}'"
);
# (un)set RELAYCLIENT in the environment as appropriate
if($pbsmtp) {
  $ENV{RELAYCLIENT} = "";
} else {
  delete $ENV{RELAYCLIENT};
}
# exec the next program in the chain...
exec @ARGV;

That should do it, but again I would like to stress that this code has NEVER BEEN TESTED, and if you use it in a production system it, is likely to error out at an inopportune time and cause you to LOSE EMAIL.

Hope this helps,
Blake

[EMAIL PROTECTED] wrote:
Hi all!!

I need install smtp-auth or pop before smtp but i dont's found nothing to
this in my configuration (qmail + dbmail + postgresql)

I found in the list one person to have a "checkpassword" work with qmail +
dbmail but the direction he's indicate it's down (
http://www.squeakerbill.com/dbmail/ )

On the other hand, i try to create in my postgresql, how indicate in
manual, a table caled pbsp, and i put "yes" in the /etc/dbmail.conf,
hoping that dbmail-pop3d or dbmail-imap add to this table "IP" for the
last consult of user's, but nothing..

Anyboy work dbmail + qmail + postgresl, or some light about this???

thank's for all...


Reply via email to