authheaders
raw JSON → 0.16.3 verified Fri May 01 auth: no python
A library wrapping email authentication header verification and generation, supporting DKIM, SPF, and DMARC. Current version 0.16.3, release cadence irregular with updates every few months.
pip install authheaders Common errors
error AttributeError: module 'authheaders' has no attribute 'authentic_headers' ↓
cause Wrong import path; trying to import from wrong module.
fix
Use: from authheaders import authentic_headers
error ModuleNotFoundError: No module named 'authres' ↓
cause Missing dependency 'authres' (authentication-results package).
fix
pip install authres
error AttributeError: module 'authheaders' has no attribute 'dkim' ↓
cause The function 'dkim' is not directly exposed; you must import the submodule correctly.
fix
Use: from authheaders import dkim
error TypeError: authentic_headers() missing 1 required positional argument: 'mfrom' ↓
cause Incorrect call signature; 'mfrom' parameter required for DKIM/SPF.
fix
Provide all required arguments: authentic_headers(headers, ip, mfrom, helo=None, ...)
Warnings
deprecated The 'publicsuffix' package is deprecated; use 'publicsuffix2' instead. authheaders switched in 0.13.0. ↓
fix pip install publicsuffix2 and ensure authheaders >=0.13.0
breaking Removed 'importlib_resources' dependency in 0.16.1; now uses 'importlib.resources' (Python 3.9+). May break on Python 3.7/3.8. ↓
fix Use Python >=3.9 or pin to authheaders==0.16.0
gotcha The 'authentic_headers' function expects headers as a dict with case-insensitive keys. Providing 'From' instead of 'from' can cause silent failures. ↓
fix Ensure header keys are lowercase (e.g., 'from', 'to', 'subject')
gotcha The library may raise 'authheaders.errors.AuthError' for various failures; catch it explicitly. ↓
fix from authheaders.errors import AuthError
Imports
- authentic_headers wrong
from authheaders.authheaders import authentic_headerscorrectfrom authheaders import authentic_headers - dkim wrong
import authheaders.dkimcorrectfrom authheaders import dkim - spf wrong
import authheaders.spfcorrectfrom authheaders import spf
Quickstart
from authheaders import authentic_headers
# Generate authentication-results header for a single email
headers = {'from': 'sender@example.com', 'to': 'recipient@example.com', 'subject': 'Test'}
result = authentic_headers(headers, '127.0.0.1', 'example.com', spf_timeout=5, dkim_timeout=5, dmarc_timeout=5)
print(result)