https://github.com/jichu4n/srslib
Sender Rewriting Scheme (SRS) library for Python
https://github.com/jichu4n/srslib
mailserver python
Last synced: 10 months ago
JSON representation
Sender Rewriting Scheme (SRS) library for Python
- Host: GitHub
- URL: https://github.com/jichu4n/srslib
- Owner: jichu4n
- License: apache-2.0
- Created: 2017-07-27T01:53:46.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-05-10T21:32:18.000Z (almost 2 years ago)
- Last Synced: 2025-03-29T13:12:18.611Z (11 months ago)
- Topics: mailserver, python
- Language: Python
- Homepage: https://srslib.readthedocs.io/
- Size: 200 KB
- Stars: 6
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# srslib - Sender Rewriting Scheme (SRS) library for Python
**srslib** is a modern Python implementation of the [Sender Rewriting Scheme (SRS)](https://en.wikipedia.org/wiki/Sender_Rewriting_Scheme).
* Compatible with Python 2.7 and 3.x
* Implements the standard "Guarded" SRS scheme as described in the [original SRS paper](http://www.libsrs2.org/srs/srs.pdf)
## Installation
```sh
pip install srslib
```
## Example Usage
```py
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
# Check if addresses are valid SRS addresses.
assert not srslib.SRS.is_srs_address('alice@A.com')
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](http://www.libsrs2.org/srs/srs.pdf), and taking inspiration from the canonical [libsrs2](https://github.com/shevek/libsrs2) C implementation and the older [pysrs](http://www.bmsi.com/python/pysrs.html) library (which itself is based on the
[Mail::SRS](http://search.cpan.org/~shevek/Mail-SRS-0.31/lib/Mail/SRS.pm) 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.