Pretty sure he meant:

my ( $self, $transaction, $recipient) = @_;
my $sender = $transaction->sender;

Then you can do:

my $recipientdomain = $recipient->host;
my $senderdomain = $sender->host;

-Jared 

Steve Freegard <steve.freeg...@fsl.com> wrote:

>Hi Tapio,
>
>On 11 Jan 2011, at 11:34, Tapio Salonsaari wrote:
>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>> 
>> Hello!
>> 
>> I'm building an web-based gui for qpsmtpd and currently I'm
>> writing/modifying plugin for white/blacklists per domain.
>> 
>> My web gui stores black / white lists into psql-database and the idea is
>> to do an SQL-search like:
>> SELECT * FROM blacklist WHERE sender="$senderdomain" AND
>> recipient="$recipientdomain";
>> 
>> Then if the query returns any rows the plugin would return DENY. If
>> there's no rows on blacklist search the same for whitelist -table and
>> process the data accordingly.
>> 
>> I'm using http://devin.com/qpsmtpd/whitelist as an base (don't know if
>> there's something more suitable to start with) and currently I'm stuck
>> with sub mail_handler, since I can't figure out how to pass both sender
>> and recipient addresses to function.
>> 
>
>You can't do anything with the recipient addresses in the mail handler because 
>they haven't been received yet!  In an SMTP transaction the recipients are 
>sent after the MAIL command (see rfc5321).
>
>If you're going to do black/whitelisting using SQL like that; then you'll need 
>to do it in the hook_rcpt handler.  As per the wiki docs at 
>http://wiki.qpsmtpd.org/api:plugin_hooks the hook_rcpt function is passed:
>
>my ($self,$transaction, $sender) = @_;
>  # $sender: an Qpsmtpd::Address object for sender of the message
>
>You can access the sender in the same format (as a Qpsmtpd::Address object) 
>via $transaction->sender at this point.
>
>Hope that helps.
>
>Kind regards,
>Steve.

Reply via email to