Wednesday, August 27, 2003

Hello Everyone,
 
I have implemented this for pop before smtp:


qpsmtpd/plugins> cat check_pop_table
### BEGIN ###

sub register {
   my ($self) = shift;
   $self->register_hook("rcpt", "check_pop_table");
}


sub check_pop_table {
   use DBI;
   my ($self) = shift;
   my($dbh) = DBI->connect('DBI:mysql:vpopmail:localhost', 'USERNAME', 'PASSWORD', 
{RaiseError =>1, AutoCommit => 1})|| die "Database connection not made: $DBI::errstr";

# Get users authenticated in the past 24 hours.
   my ($allowed) = $dbh->selectrow_array(q[select ip_addr from vpopmail.relay where 
ip_addr = ? and (to_days(now()) - to_days(from_unixtime(timestamp)) <2)],{}, 
$self->qp->connection->remote_ip);

# Send mail through
   return (OK) if $allowed;

# uh-oh, bye-bye

   return (DENY);
}
### END ###

-- 
Best regards,

Ashish                          
mailto:[EMAIL PROTECTED]

We didn't lose the game; we just ran out of time. - Vince Lombardi
*********************************************************************
  Internet Wizards - The finest in web services! http://www.inwiz.com
*********************************************************************

Tuesday, August 26, 2003, 9:40:00 PM IST, [EMAIL PROTECTED] wrote:


ABH> On Tuesday, Aug 26, 2003, at 08:32 America/Los_Angeles, Ashish Pawaskar 
ABH> wrote:

>> Can anyone give any pointers as to how i can have the check_relay
>> plugin check the mysql table? I can't figure out where I can find the
>> IP address of the sender.

ABH> Make a new plugin, not entirely unlike the following and put it in your 
ABH> configuration to run before check_relay.

ABH> sub register {
ABH>    my ($self) = shift;
ABH>    $self->register_hook("rcpt", "check_pop_table");
ABH> }

ABH> sub check_pop_table {
ABH>    my ($self) = shift;

ABH>    my $dbh = DBI->connect(...);
ABH>    my ($allowed) = $dbh->selectrow_array(q[select foo from table where 
ABH> ip = ?],
ABH>                                                                     {}, 
$self->>qp->connection->remote_ip);

ABH>    return OK if $allowed;

ABH>    return DECLINE;
ABH> }


ABH> (I wrote this in Mail.app, so apologies if it doesn't indent or syntax 
ABH> check properly).


ABH>   - ask

Reply via email to