From d0fe3b0b848e0ab91aa15e1ee2d51b5a5c8295ef Mon Sep 17 00:00:00 2001
From: Stuart Gathman <stuart@gathman.org>
Date: Wed, 10 Oct 2007 18:07:50 +0000
Subject: [PATCH] Check porn keywords in From header field.

---
 bms.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/bms.py b/bms.py
index 2a6e4ed..f71d7ca 100644
--- a/bms.py
+++ b/bms.py
@@ -1,6 +1,9 @@
 #!/usr/bin/env python
 # A simple milter that has grown quite a bit.
 # $Log$
+# Revision 1.113  2007/09/25 16:37:26  customdesigned
+# Tested on RH7
+#
 # Revision 1.112  2007/09/13 14:51:03  customdesigned
 # Report domain on reputation reject.
 #
@@ -1179,7 +1182,14 @@ class bmsMilter(Milter.Milter):
           # original sender (encoded in Message-ID) is blacklisted
 
     elif lname == 'from':
-      name,email = parseaddr(val)
+      fname,email = parseaddr(val)
+      # check for porn keywords
+      lval = fname.lower().strip()
+      for w in porn_words:
+        if lval.find(w) >= 0:
+          self.log('REJECT: %s: %s' % (name,val))
+          self.setreply('550','5.7.1','Watch your language')
+          return Milter.REJECT
       if email.lower().startswith('postmaster@'):
         # Yes, if From header comes last, this might not help much.
         # But this is a heuristic - if MTAs would send proper DSNs in
-- 
GitLab