Skip to main content

Sender Rewriting Scheme (SRS) library for Python

Project description

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 alice@A.com to B.com
rewritten_addr = srs.forward('alice@A.com', 'B.com')
# => 'SRS0=ZPM1=67=A.com=alice@B.com'

# Reverse it to get the address to bounce to.
try:
  bounce_addr = srs.reverse(rewritten_addr)
  # => 'alice@A.com'
except srslib.Error as e:
  ...  # Handle errors

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
srslib-0.1.4-py2-none-any.whl (8.1 kB) Copy SHA256 hash SHA256 Wheel py2
srslib-0.1.4-py3-none-any.whl (8.1 kB) Copy SHA256 hash SHA256 Wheel py3
srslib-0.1.4.tar.gz (6.1 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page