SPF (Sender Policy Framework) implemented in Python.
Likely abandoned. No release or commit for years (last release over 6 years ago).
pip install pyspfSPF
Sender-Policy-Framework queries in Python.
Quick Start
Installation
This package requires either the dns (dnspython) or DNS (PyDNS/Py3DNS modules and either the ipaddr module or python3.3 and later. It does not work with the ipaddress module backport. For dnspython, at least version 1.16.0 is required. The authres module is required to process and generate RFC 7601 Authentication Results headers. These can all be installed from pypi via pip. Additionally, they are also available via many distribution packaging systems.
pyspf uses traditional python distutils, so dependencies are not installed automatically. pyspf can be installed from pypi via pip or manually:
After unpacking the source distribution, install this in your site- specific Python extension directory::
% python setup.py build
% su
# python setup.py install
The minimum Python version required is python2.6. The spf module in this version has been tested with python3 versions through python3.8.
Testing
After this package is installed, cd into the test directory and execute testspf.py::
% cd test
% python testspf.py
WARN: invalid-domain-long in rfc4408-tests.yml, 8.1/2, 5/10: fail preferred to temperror
WARN: txttimeout in rfc4408-tests.yml, 4.4/1: fail preferred to temperror
WARN: spfoverride in rfc4408-tests.yml, 4.5/5: pass preferred to fail
WARN: multitxt1 in rfc4408-tests.yml, 4.5/5: pass preferred to permerror
WARN: multispf2 in rfc4408-tests.yml, 4.5/6: permerror preferred to pass
..
----------------------------------------------------------------------
Ran 2 tests in 3.036s
OK
This runs the SPF council test-suite as of when this package was built. It does not test the pyDNS installation, but uses an internal driver. This avoids changing results due to DNS timeouts.
In addition, spf.py runs an internal self-test every time it is used from the command line.
If you're running on Mac OS X, and it looks like DNS.DiscoverNameServers() is failing, you'll need to edit your /etc/resolv.conf and specify a domain name. For some reason, OS X writes out resolv.conf with a single 'domain' line, which isn't good at all. Later versions of py3dns have been updated to better support Max OS X.
Description
SPF does email sender validation. For more information about SPF, please see http://www.openspf.net/
One incompatible change was introduced in version 1.7. Prior to version 1.7, connections from a local IP address (127...) would always return a Pass result. The special case was eliminated. Programs calling pySPF should not do SPF checks on locally submitted mail.
This SPF client is intended to be installed on the border MTA, checking if incoming SMTP clients are permitted to forward mail. The SPF check should be done during the MAIL FROM:<...> command.