From 981bdf5f852c2958467d40b5fa17db571d8e291c Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Wed, 24 Apr 2013 16:18:22 -0400 Subject: [PATCH] SPF: added more precise disposition logs, so that postprocess can determine if a SPF failure caused a rejection --- plugins/sender_permitted_from | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/plugins/sender_permitted_from b/plugins/sender_permitted_from index 87d418d..e80b4e4 100644 --- a/plugins/sender_permitted_from +++ b/plugins/sender_permitted_from @@ -151,22 +151,25 @@ sub mail_handler { return $self->handle_code_softfail($reject, $why) if $code eq 'softfail'; if ($code eq 'neutral') { - $self->log(LOGINFO, "fail, $code, $why"); - return (DENY, "SPF - $code: $why") if $reject >= 5; + if ($reject >= 5 ) { + $self->log(LOGINFO, "fail, $code, $why"); + return (DENY, "SPF - $code: $why"); + }; + $self->log(LOGINFO, "fail, tolerated, $code, $why"); + return (DECLINED); } - elsif ($code eq 'error') { - $self->log(LOGINFO, "fail, $code, $why"); + if ($code =~ /(?:permerror|error)/ ) { + $self->log(LOGINFO, "fail, $code, $why") if $reject > 3; return (DENY, "SPF - $code: $why") if $reject >= 6; return (DENYSOFT, "SPF - $code: $why") if $reject > 3; + $self->log(LOGINFO, "fail, tolerated, $code, $why"); + return (DECLINED); } - elsif ($code eq 'permerror') { - $self->log(LOGINFO, "fail, $code, $why"); - return (DENY, "SPF - $code: $why") if $reject >= 6; - return (DENYSOFT, "SPF - $code: $why") if $reject > 3; - } - elsif ($code eq 'temperror') { + if ($code eq 'temperror') { $self->log(LOGINFO, "fail, $code, $why"); return (DENYSOFT, "SPF - $code: $why") if $reject >= 2; + $self->log(LOGINFO, "fail, tolerated, $code, $why"); + return (DECLINED); } $self->log(LOGINFO, "SPF from $from was $code: $why"); @@ -211,7 +214,7 @@ sub handle_code_softfail { return (DENYSOFT, "SPF - fail: $why") if $reject >= 3; } - $self->log(LOGINFO, "fail, soft, tolerated, $why"); + $self->log(LOGINFO, "fail, tolerated, soft, $why"); return DECLINED; }