On Sat, 2006-12-2006 09:17 Hanno Hecker wrote:
> Hi Joe,
>
> On Sat, 30 Dec 2006 05:11:00 +0100
>
> Joe Knall <[EMAIL PROTECTED]> wrote:
> > I'm new to qpsmtpd and want a plugin for userdefined
> > black/whitelisting of senders. The plugin should look up in a
> > database if the recipient has listed the current sender and react
> > appropriate (allow, drop, redirect).
> > So my question is, is there a hook that provides sender _and_
> > recipient (hook_mail and hook_rcpt)?
>
> In hook_mail you just have the sender, as no RCPT TO: has been sent
> at this point. In hook_rcpt you can get the sender and recipient by
> something like this:
>
> sub hook_rcpt {
>     my ($self, $transaction, $recipient, %param) = @_;
>     my $sender = $transaction->sender;
>
> Both ($sender, $recipient) are Qpsmtpd::Address objects.

Thanks a lot, this does exactly what it should :)

Next question: where to initialize the connection to my database?
I think the init-method should be the correct place, isn't it?
And should it be stored in $connection->notes?
Is there maybe a better place?

looks like this:
my $dbh;
eval {
    $dbh = DBI->connect(
        $dbConfig{dsn},
        $dbConfig{user},
        $dbConfig{password},
        {'RaiseError' => 1}
    )
};
die ("Can't connect to db:[EMAIL PROTECTED]") if $@;

Thanks, Joe

Reply via email to