Guy,
> I've been trying to use policyd v2 with amavis, but I'm getting an
> error in the logs from one of the commands in the custom script
> amavisd-policyd.pm included for integration with amavis.
>
> sub process_policy {
> my($self,$conn,$msginfo,$pbn) = @_;
> do_log(5,"policyd/process_policy: Starting");
> # Get message ID
> my ($lastReceived) = $msginfo->orig_header_fields->{'received'};
> do_log(-1,"lastReceived = '$lastReceived'");
> if (!($lastReceived =~ /with E?SMTP id ([0-9A-Z]+)/)) {
> do_log(-1,"policyd/process_policy: Failed to parse in
> queue id from received line '$lastReceived'");
> return $pbn;
> }
>
> The variable "$lastReceived" contains a single digit rather than the
> line I would have expected to be returned.
Yes, it is a index, rather than a text itself:
sub orig_header_fields
# orig. header fields indices (LAST occurence) - hashref
Do not access it directly, use the get_header_field subroutine instead:
# return a j-th header field with a given field name, along with its index
# into the array of all header fields; if a field name is undef then all
# header fields are considered; search proceeds top-down if j >= 0,
# or bottom up for negative values (-1=last, -2=next-to-last, ...);
# access to the last header field (j=-1) is optimized and avoids a
# sequential scan; undefined j is equivalent to -1
#
sub get_header_field {
my($self,$field_name,$j) = @_;
or the get_header_field_body for a simplied access to the
header field body:
sub get_header_field_body {
my($self,$field_name,$j) = @_;
my($k); my($f_i,$f_n,$f) = $self->get_header_field($field_name,$j);
defined $f && ($k=index($f,':')) >= 0 ? substr($f,$k+1) : $f;
}
So that would be:
my($lastReceived) =
$msginfo->get_header_field_body('received'); # last
Mark
------------------------------------------------------------------------------
_______________________________________________
AMaViS-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/amavis-user
AMaViS-FAQ:http://www.amavis.org/amavis-faq.php3
AMaViS-HowTos:http://www.amavis.org/howto/