diff src/context.cpp @ 167:9b129ed78d7d stable-6-0-6

actually use spamassassin result, allow build without spam assassin, only call it if some recipient needs it.
author carl
date Mon, 27 Aug 2007 20:49:19 -0700
parents 5809bcdc325b
children 6bac960af6b4
line wrap: on
line diff
--- a/src/context.cpp	Sun Aug 26 20:54:59 2007 -0700
+++ b/src/context.cpp	Mon Aug 27 20:49:19 2007 -0700
@@ -646,11 +646,12 @@
 
 
 void CONFIG::dump() {
-	if (default_context) default_context->dump(true);
+	bool spamass = false;
+	if (default_context) default_context->dump(true, spamass);
 	for (context_list::iterator i=contexts.begin(); i!=contexts.end(); i++) {
 		CONTEXTP c = *i;
 		CONTEXTP p = c->get_parent();
-		if (!p && (c != default_context)) c->dump(false);
+		if (!p && (c != default_context)) c->dump(false, spamass);
 	}
 	char buf[maxlen];
 	for (context_map::iterator i=env_to.begin(); i!=env_to.end(); i++) {
@@ -658,6 +659,9 @@
 		CONTEXTP con = (*i).second;
 		printf("// envelope to %s \t-> context %s \n", to, con->get_full_name(buf,maxlen));
 	}
+	if (spamass && (spamc == spamc_empty)) {
+		printf("// *** warning - spamassassin filtering requested, but spamc not found by autoconf.\n");
+	}
 }
 
 
@@ -863,23 +867,26 @@
 }
 
 
-bool CONTEXT::acceptable_content(recorder &memory, int score, char *&msg) {
+bool CONTEXT::acceptable_content(recorder &memory, int score, string& msg) {
 	if (spamassassin_limit && (score > spamassassin_limit)) {
-		msg = "Mail rejected by spam assassin";
+		char buf[maxlen];
+		snprintf(buf, sizeof(buf), "Mail rejected - spam assassin score %d", score);
+		msg = string(buf);
+		return false;
 	}
 	if (memory.excessive_bad_tags(tag_limit)) {
-		msg = tag_limit_message;
+		msg = string(tag_limit_message);
 		return false;
 	}
 	if (!host_random && memory.excessive_hosts(host_limit)) {
-		msg = host_limit_message;
+		msg = string(host_limit_message);
 		return false;
 	}
 	return true;
 }
 
 
-void CONTEXT::dump(bool isdefault, int level) {
+void CONTEXT::dump(bool isdefault, bool &spamass, int level) {
 	char indent[maxlen];
 	int i = min(maxlen-1, level*4);
 	memset(indent, ' ', i);
@@ -960,6 +967,7 @@
 		}
 		printf("%s         spamassassin %d; \n", indent, spamassassin_limit);
 		printf("%s     }; \n", indent);
+		spamass |= (spamassassin_limit != 0);
 		}
 	else {
 		printf("%s     content off {}; \n", indent, env_from_default);
@@ -981,7 +989,7 @@
 
 	for (context_map::iterator i=children.begin(); i!=children.end(); i++) {
 		CONTEXTP c = (*i).second;
-		c->dump(false, level+1);
+		c->dump(false, spamass, level+1);
 	}
 
 	printf("%s     env_from %s { \t// %s\n", indent, env_from_default, fullname);