authres

raw JSON →
1.2.0 verified Mon Apr 27 auth: no python

A Python library for parsing and generating email Authentication-Results headers as defined in RFC 8601. Current version 1.2.0, stable release cadence is low (last update 2021).

pip install authres
error AttributeError: module 'authres' has no attribute 'AuthenticationResultsHeader'
cause The import path is correct but some installations may have a different version or package name collision.
fix
Run 'pip install --upgrade authres' to ensure version 1.2.0 installed.
error TypeError: AuthenticationResultsHeader.parse() takes 1 positional argument but 2 were given
cause Trying to pass additional parameters like instance method incorrectly.
fix
Use AuthenticationResultsHeader.parse(header_string) without extra arguments.
error ValueError: Invalid header format
cause Header string does not conform to RFC 8601 syntax, e.g., missing '=' in key-value pairs.
fix
Ensure header format: 'method=result key=value' with spaces separating key-value pairs.
gotcha The library only supports RFC 8601, not earlier drafts. Headers using 'smtp.mailfrom' (with dot) vs 'smtp.mailfrom' (underscore) may cause parsing issues.
fix Ensure your header strings use RFC 8601 format exactly.
gotcha Parsing multiple header lines requires concatenating them with newlines; passing them as separate arguments is not supported.
fix Supply the entire header value as a single string, with newlines separating lines if multi-line.
deprecated The library is no longer actively maintained; no updates since 2021. It may not work with future Python versions.
fix Consider alternatives or pin Python version (tested up to 3.10).

Parse and generate Authentication-Results headers.

from authres import AuthenticationResultsHeader

# Parse an Authentication-Results header
header = 'dmarc=pass header.from=example.com; spf=pass smtp.mailfrom=email@example.com'
parsed = AuthenticationResultsHeader.parse(header)
print(parsed.results)

# Generate a new header
from authres import AuthenticationResultsHeader, AuthResult
result = AuthResult('dmarc', 'pass', {'header.from': 'example.com'})
header_obj = AuthenticationResultsHeader('mail.example.com', [result])
print(str(header_obj))