diff src/dnsbl.cpp @ 152:c7fc218686f5

gpl3, block mail to recipients that cannot reply
author carl
date Sat, 07 Jul 2007 10:26:31 -0700
parents a23ef169d322
children 8d7c439bb6fa
line wrap: on
line diff
--- a/src/dnsbl.cpp	Tue Mar 27 15:24:43 2007 -0700
+++ b/src/dnsbl.cpp	Sat Jul 07 10:26:31 2007 -0700
@@ -1,8 +1,8 @@
 /*
 
-Copyright (c) 2006 Carl Byington - 510 Software Group, released
-under the GPL version 2 or any later version at your choice available at
-http://www.fsf.org/licenses/gpl.txt
+Copyright (c) 2007 Carl Byington - 510 Software Group, released under
+the GPL version 3 or any later version at your choice available at
+http://www.gnu.org/licenses/gpl-3.0.txt
 
 Based on a sample milter Copyright (c) 2000-2003 Sendmail, Inc. and its
 suppliers.	Inspired by the DCC by Rhyolite Software
@@ -952,17 +952,25 @@
 	if (!priv.queueid) priv.queueid = strdup(smfi_getsymval(ctx, "i"));
 	char *rcptaddr	= rcpt[0];
 	char *loto		= to_lower_string(rcptaddr);
+	// priv.mailaddr sending original message to loto
 	CONTEXT    &con = *(dc.find_context(loto)->find_context(priv.mailaddr));
 	VERIFYP 	ver = con.find_verify(loto);
+	char  *fromvalue = con.find_from(priv.mailaddr);
+	// loto sending a reply back to priv.mailaddr
+	CONTEXT    &con2 = *(dc.find_context(priv.mailaddr)->find_context(loto));
+	char *replyvalue = con2.find_from(loto);
 	if (debug_syslog > 1) {
 		char buf[maxlen];
 		char msg[maxlen];
-		snprintf(msg, sizeof(msg), "from <%s> to <%s> using context %s", priv.mailaddr, loto, con.get_full_name(buf,maxlen));
+		snprintf(msg, sizeof(msg), "from <%s> to <%s> using context %s out %s reply %s", priv.mailaddr, loto, con.get_full_name(buf,maxlen), fromvalue, replyvalue);
 		my_syslog(&priv, msg);
 	}
 	free(loto);
-	char *fromvalue = con.find_from(priv.mailaddr);
 	status st;
+	if (replyvalue == token_black) {
+		smfi_setreply(ctx, "550", "5.7.1", "recipient can not reply due to blacklisting");
+		return SMFIS_REJECT;
+	}
 	if (priv.authenticated) {
 		int c = incr_rcpt_count(priv.authenticated);
 		int l = dc.default_context->find_rate(priv.authenticated);