Skip to content

Node.js wrapper around Python's spf.check2 function which conforms to both RFC4408 and RFC7208

License

Notifications You must be signed in to change notification settings

radiantly/python-spfcheck2

 
 

Repository files navigation

python-spfcheck2

build status code coverage code style styled with prettier made with lass license npm downloads

Node.js wrapper around Python's spf.check2 function which conforms to both RFC4408 and RFC7208

Table of Contents

Requirements

  1. Ensure that you have a Python version of >=2.6 installed per pyspf requirements:

    python --version
  2. Install the package "pyspf" using pip globally:

    pip install pyspf
  3. Install the DNS package based off your version of Python:

    If you are using Python version >= 3:

    pip install py3dns

    Otherwise install the older version (note 2.3.4 is the only version that seems to work OK on Mac):

    pip install pydns==2.3.4
  4. Lastly if you are using Python version < 3.3 you will need to install "ipaddr" package:

    pip install ipaddr

Install

npm:

npm install python-spfcheck2

yarn:

yarn add python-spfcheck2

Usage

const spfCheck2 = require('python-spfcheck2');

const ip = '69.55.226.139';
const address = 'terry@wayforward.net';
const host = 'mx1.wayforward.net';

// then/catch usage
spfCheck2(ip, address, host)
  .then([result, explanation] => console.log(result, explanation))
  .catch(console.error);

// async/await usage
(async () => {
  try {
    const [ result, explanation ] = await spfCheck2(ip, address, host);
    console.log(result, explanation);
  } catch (err) {
    console.error(err);
  }
})();

Note that result is a String (which also corresponds to a particular explanation), see table below for the full list:

Result Explanation
pass sender SPF authorized
fail SPF fail - not authorized
neutral permanent error in processing
softfail domain owner discourages use of this host
permerror permanent error in processing
temperror temporary DNS error in processing
none
local No SPF result due to local policy
trusted No SPF check - trusted-forwarder.org
ambiguous No error, but results may vary

An error is thrown if the child process itself (spf.check2) errors.

Contributors

Name Website
Nick Baugh http://niftylettuce.com/

License

MIT © Nick Baugh

About

Node.js wrapper around Python's spf.check2 function which conforms to both RFC4408 and RFC7208

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 85.2%
  • Python 14.8%