Even if best guess is enabled, it should only be used for none results, not 
(for example, neutral).

Scott K

diff --git a/bley b/bley
index e7f5b91..05f051b 100755
--- a/bley
+++ b/bley
@@ -254,6 +254,7 @@ def bley_start():
     settings.purge_days       = config.getint('bley', 'purge_days')
     settings.purge_bad_days   = config.getint('bley', 'purge_bad_days')
     settings.use_spf          = config.getint('bley', 'use_spf')
+    settings.use_spf_guess    = config.getint('bley', 'use_spf_guess')
 
     settings.exim_workaround  = config.getboolean('bley', 'exim_workaround')
 
diff --git a/bley.conf b/bley.conf
index 8424770..9fa1338 100644
--- a/bley.conf
+++ b/bley.conf
@@ -44,6 +44,7 @@ purge_bad_days = 10
 
 # Use SPF?
 use_spf = 1
+use_spf_guess = 0
 
 # Use Exim workaround (close the socket after an action has been sent)?
 exim_workaround = 0
diff --git a/bley.py b/bley.py
index f5be8d6..4cdfb37 100644
--- a/bley.py
+++ b/bley.py
@@ -132,7 +132,7 @@ class BleyPolicy(PostfixPolicy):
                 if postfix_params['sender']==postfix_params['recipient']:
                     check_results['S_EQ_R'] = 1
                 if self.factory.settings.use_spf and check_results['DNSBL'] < self.factory.settings.dnsbl_threshold and check_results['HELO']+check_results['DYN']+check_results['S_EQ_R'] < self.factory.settings.rfc_threshold:
-                    check_results['SPF'] = check_spf(postfix_params)
+                    check_results['SPF'] = check_spf(postfix_params, self.factory.settings.use_spf_guess)
                 else:
                     check_results['SPF'] = 0
                 if check_results['DNSBL'] >= self.factory.settings.dnsbl_threshold or check_results['HELO']+check_results['DYN']+check_results['SPF']+check_results['S_EQ_R'] >= self.factory.settings.rfc_threshold:
diff --git a/bleyhelpers.py b/bleyhelpers.py
index 73f6896..459308e 100644
--- a/bleyhelpers.py
+++ b/bleyhelpers.py
@@ -91,7 +91,7 @@ def check_helo(params):
 
     return score
 
-def check_spf(params):
+def check_spf(params, guess):
     '''Check the SPF record of the sending address.
     Try Best Guess when the domain has no SPF record.
     Returns 1 when the SPF result is in ['fail', 'softfail'],
@@ -99,6 +99,8 @@ def check_spf(params):
 
     @type  params: dict
     @param params: the params from Postfix
+    @type  guess:  int
+    @param guess:  1 if use 'best guess', 0 if not
     @rtype:        int
     @return:       1 if bad SPF, 0 else
     '''
@@ -110,7 +112,7 @@ def check_spf(params):
             score = 1
         elif r[0] in ['pass']:
             score = 0
-        else:
+        elif guess > 0 and r[0] in ['none']:
             r = s.best_guess()
             if r[0] in ['fail', 'softfail']:
                 score = 1

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to