Noah,
> Here is a patch to allow admins to customize the blocking SMTP response
> reason in a config variable. It is particularly useful for people using
> amavisd-new in milter and proxy contexts that want to customize their
> reject messages. (Especially adding a contact address).
Thanks. It seems to be a frequently requested feature indeed.
See my version of your patch below. It delegates the whole
task to %smtp_reason_by_ccat, no %x and no default reasons.
--- amavisd.orig 2009-04-22 02:24:12.000000000 +0200
+++ amavisd 2009-06-04 16:51:56.000000000 +0200
@@ -348,4 +348,5 @@
%always_bcc_by_ccat %dsn_bcc_by_ccat
%addr_extension_maps_by_ccat %addr_rewrite_maps_by_ccat
+ %smtp_reason_by_ccat
)],
'confvars' => # global settings (not per-policy, not per-recipient)
@@ -1463,4 +1464,29 @@
CC_CATCHALL, D_PASS,
);
+
+ %smtp_reason_by_ccat = (
+ CC_VIRUS, "id=%n - INFECTED: %V",
+ CC_BANNED, "id=%n - BANNED: %F",
+ CC_UNCHECKED, "id=%n - UNCHECKED",
+ CC_SPAM, "id=%n - SPAM",
+ CC_SPAMMY.',1', "id=%n - SPAMMY3",
+ CC_SPAMMY, "id=%n - SPAMMY",
+ CC_BADH, "id=%n - BAD HEADER",
+ CC_BADH.',1', "id=%n - BAD HEADER: MIME error",
+ CC_BADH.',2', "id=%n - BAD HEADER: nonencoded 8-bit character",
+ CC_BADH.',3', "id=%n - BAD HEADER: contains invalid control character",
+ CC_BADH.',4', "id=%n - BAD HEADER: line made up entirely of whitespace",
+ CC_BADH.',5', "id=%n - BAD HEADER: line longer than RFC 2822 limit",
+ CC_BADH.',6', "id=%n - BAD HEADER: syntax error",
+ CC_BADH.',7', "id=%n - BAD HEADER: missing required header field",
+ CC_BADH.',8', "id=%n - BAD HEADER: duplicate header field",
+ CC_OVERSIZED, "id=%n - Message size exceeds recipient's size limit",
+ CC_MTA, "id=%n - unable to relay message back to MTA",
+ CC_MTA.',1', "id=%n - temporary MTA failure on relaying",
+ CC_MTA.',2', "id=%n - rejected by MTA on relaying",
+ CC_CLEAN, "id=%n - CLEAN",
+ CC_CATCHALL, "id=%n - OTHER", # should not happen
+ );
+
%lovers_maps_by_ccat = (
CC_VIRUS, sub { ca('virus_lovers_maps') },
@@ -11018,41 +11044,37 @@
do_log(5, "final_destiny PASS, recip %s", $recip);
} else { # recipient does not want this content
- # supply RFC 3463 enhanced codes
- my($status_and_reason) = setting_by_given_contents_category(
+ # supply RFC 3463 enhanced status codes
+ my($status) = setting_by_given_contents_category(
$blocking_ccat,
- { CC_VIRUS,
- ["554 5.7.0", "VIRUS: " . join(", ", @virusname)],
- CC_BANNED,
- ["554 5.7.0", "BANNED: " . $r->banning_reason_short],
- CC_UNCHECKED,
- ["554 5.7.0", "UNCHECKED"],
- CC_SPAM,
- ["554 5.7.0", "SPAM". ($r->recip_blacklisted_sender ?
- ', sender blacklisted' : '')],
- CC_SPAMMY.",1",
- ["554 5.7.0", "SPAMMY (tag3)"],
- CC_SPAMMY,
- ["554 5.7.0", "SPAMMY"], # tag2
- CC_BADH.",2", # nonencoded 8-bit character
- ["554 5.6.3", "BAD_HEADER: ".(split(/\n/,$bad_headers[0]))[0]],
- CC_BADH,
- ["554 5.6.0", "BAD_HEADER: ".(split(/\n/,$bad_headers[0]))[0]],
- CC_OVERSIZED,
- ["552 5.3.4", "Message size ($mail_size B) ".
- "exceeds recipient's size limit"],
- CC_CATCHALL, ["554 5.7.0", "CLEAN"],
+ { CC_VIRUS, "554 5.7.0",
+ CC_BANNED, "554 5.7.0",
+ CC_UNCHECKED, "554 5.7.0",
+ CC_SPAM, "554 5.7.0",
+ CC_SPAMMY, "554 5.7.0",
+ CC_BADH.",2", "554 5.6.3", # nonencoded 8-bit character
+ CC_BADH, "554 5.6.0",
+ CC_OVERSIZED, "552 5.3.4",
+ CC_CATCHALL, "554 5.7.0",
});
- my($status,$reason);
- ($status,$reason) = @$status_and_reason if $status_and_reason;
$final_destiny!=D_PASS or die "Assert failed: $final_destiny==pass";
- $reason = substr($reason,0,100)."..." if length($reason) > 100+3;
if ($final_destiny == D_DISCARD) {
local($1,$2);
$status =~ s{^5(\d\d) 5(\.\d\.\d)\z}{250 2$2}; # 5xx -> 250
}
- my($response) = $status . ' ' .
+ # get the custom smtp response reason text
+ my($smtp_reason) = setting_by_given_contents_category(
+ $blocking_ccat, cr('smtp_reason_by_ccat'));
+ $smtp_reason = '' if !defined $smtp_reason;
+ if ($smtp_reason ne '') {
+ my(%mybuiltins) = %builtins; # make a local copy
+ $smtp_reason = expand(\$smtp_reason, \%mybuiltins);
+ $smtp_reason = !ref($smtp_reason) ? '' : ${$smtp_reason};
+ $smtp_reason = substr($smtp_reason,0,100) . "..."
+ if length($smtp_reason) > 100+3;
+ }
+ my($response) = sprintf("%s %s%s", $status,
($final_destiny == D_PASS ? "Ok" :
- $final_destiny == D_DISCARD ? "Ok, discarded" : "Reject") .
- ", id=$am_id - $reason";
+ $final_destiny == D_DISCARD ? "Ok, discarded" : "Reject"),
+ $smtp_reason eq '' ? '' : ', '.$smtp_reason);
ll(4) && do_log(4, "blocking ccat=%s, SMTP response: %s",
$blocking_ccat,$response);
Mark
------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises
looking to deploy the next generation of Solaris that includes the latest
innovations from Sun and the OpenSource community. Download a copy and
enjoy capabilities such as Networking, Storage and Virtualization.
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
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/