The script now operates in monitoring/observation mode, where SPF results are recorded in headers but never cause email rejection or deferral.

This commit is contained in:
nemunaire 2025-10-15 21:15:05 +07:00
commit 5db125ae86
2 changed files with 20 additions and 12 deletions

View file

@ -348,8 +348,8 @@ sub sender_policy_framework {
); );
}; };
# Reject on HELO fail. Defer on HELO temperror if message would otherwise # Prepend header on HELO fail instead of rejecting.
# be accepted. Use the HELO result and return for null sender. # Use the HELO result and return for null sender.
if ($helo_result->is_code('fail')) { if ($helo_result->is_code('fail')) {
if ($VERBOSE) { if ($VERBOSE) {
syslog( syslog(
@ -358,7 +358,8 @@ sub sender_policy_framework {
$attr->{helo_name} || '<UNKNOWN>' $attr->{helo_name} || '<UNKNOWN>'
); );
}; };
return "550 $helo_authority_exp"; return "PREPEND $helo_spf_header"
unless $cache->{added_spf_header}++;
} }
elsif ($helo_result->is_code('temperror')) { elsif ($helo_result->is_code('temperror')) {
if ($VERBOSE) { if ($VERBOSE) {
@ -368,7 +369,8 @@ sub sender_policy_framework {
$attr->{helo_name} || '<UNKNOWN>' $attr->{helo_name} || '<UNKNOWN>'
); );
}; };
return "DEFER_IF_PERMIT SPF-Result=$helo_local_exp"; return "PREPEND $helo_spf_header"
unless $cache->{added_spf_header}++;
} }
elsif ($attr->{sender} eq '') { elsif ($attr->{sender} eq '') {
if ($VERBOSE) { if ($VERBOSE) {
@ -442,10 +444,12 @@ sub sender_policy_framework {
); );
}; };
if ($mfrom_result->is_code('fail')) { if ($mfrom_result->is_code('fail')) {
return "550 $mfrom_authority_exp"; return "PREPEND $mfrom_spf_header"
unless $cache->{added_spf_header}++;
} }
elsif ($mfrom_result->is_code('temperror')) { elsif ($mfrom_result->is_code('temperror')) {
return "DEFER_IF_PERMIT SPF-Result=$mfrom_local_exp"; return "PREPEND $mfrom_spf_header"
unless $cache->{added_spf_header}++;
} }
else { else {
return "PREPEND $mfrom_spf_header" return "PREPEND $mfrom_spf_header"

View file

@ -348,8 +348,8 @@ sub sender_policy_framework {
); );
}; };
# Reject on HELO fail. Defer on HELO temperror if message would otherwise # Prepend header on HELO fail instead of rejecting.
# be accepted. Use the HELO result and return for null sender. # Use the HELO result and return for null sender.
if ($helo_result->is_code('fail')) { if ($helo_result->is_code('fail')) {
if ($VERBOSE) { if ($VERBOSE) {
syslog( syslog(
@ -358,7 +358,8 @@ sub sender_policy_framework {
$attr->{helo_name} || '<UNKNOWN>' $attr->{helo_name} || '<UNKNOWN>'
); );
}; };
return "550 $helo_authority_exp"; return "PREPEND $helo_spf_header"
unless $cache->{added_spf_header}++;
} }
elsif ($helo_result->is_code('temperror')) { elsif ($helo_result->is_code('temperror')) {
if ($VERBOSE) { if ($VERBOSE) {
@ -368,7 +369,8 @@ sub sender_policy_framework {
$attr->{helo_name} || '<UNKNOWN>' $attr->{helo_name} || '<UNKNOWN>'
); );
}; };
return "DEFER_IF_PERMIT SPF-Result=$helo_local_exp"; return "PREPEND $helo_spf_header"
unless $cache->{added_spf_header}++;
} }
elsif ($attr->{sender} eq '') { elsif ($attr->{sender} eq '') {
if ($VERBOSE) { if ($VERBOSE) {
@ -442,10 +444,12 @@ sub sender_policy_framework {
); );
}; };
if ($mfrom_result->is_code('fail')) { if ($mfrom_result->is_code('fail')) {
return "550 $mfrom_authority_exp"; return "PREPEND $mfrom_spf_header"
unless $cache->{added_spf_header}++;
} }
elsif ($mfrom_result->is_code('temperror')) { elsif ($mfrom_result->is_code('temperror')) {
return "DEFER_IF_PERMIT SPF-Result=$mfrom_local_exp"; return "PREPEND $mfrom_spf_header"
unless $cache->{added_spf_header}++;
} }
else { else {
return "PREPEND $mfrom_spf_header" return "PREPEND $mfrom_spf_header"