Skip to content
forked from jichu4n/srslib

Sender Rewriting Scheme (SRS) library for Python

License

Notifications You must be signed in to change notification settings

oasiswork/srslib

 
 

Repository files navigation

srslib - Sender Rewriting Scheme (SRS) library for Python

srslib is a modern Python implementation of the Sender Rewriting Scheme (SRS).

Highlights:

  • Compatible with Python 2.7 and 3.x;
  • Implements the standard "Guarded" SRS scheme as described in the original SRS paper;
  • Simple to use and understand.

Installation

pip install srslib

Example Usage

import srslib

srs = srslib.SRS('my_secret_key')

# Rewrites an email from [email protected] to B.com
rewritten_addr = srs.forward('[email protected]', 'B.com')
# => '[email protected]'

# Reverse it to get the address to bounce to.
try:
  bounce_addr = srs.reverse(rewritten_addr)
  # => '[email protected]'
except srslib.Error as e:
  ...  # Handle errors

# Check if addresses are valid SRS addresses.
assert not srslib.SRS.is_srs_address('[email protected]')
assert srslib.SRS.is_srs_address(rewritten_addr)

Documentation

The full documentation for srslib lives at https://srslib.readthedocs.io/.

Implementation

This library is a clean re-implementation of SRS in modern Python based on the original SRS paper, and taking inspiration from the canonical libsrs2 C implementation and the older pysrs library (which itself is based on the Mail::SRS Perl package).

Compared to these two libraries, srslib

  • ... is a clean, modern, pure-Python implementation and supports Python 3.x;
  • ... discards baggage from Mail::SRS around legacy schemes and settings.

License

Licensed under the Apache License, Version 2.0.

About

Sender Rewriting Scheme (SRS) library for Python

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 92.3%
  • Makefile 7.7%