Mail::SRS is a Perl interface to Sender Rewriting Scheme.
my $srs = new Mail::SRS(
Secret => [ .... ], # scalar or array
MaxAge => 49, # days
HashLength => 4, # base64 characters: 4 x 6bits
HashMin => 4, # base64 characters
my $srsaddress = $srs->forward($sender, $alias);
my $sender = $srs->reverse($srsaddress);
The Sender Rewriting Scheme preserves .forward functionality in an SPF-compliant world.
SPF requires the SMTP client IP to match the envelope sender (return-path). When a message is forwarded through an intermediate server, that intermediate server may need to rewrite the return-path to remain SPF compliant. If the message bounces, that intermediate server needs to validate the bounce and forward the bounce to the original sender.
SRS provides a convention for return-path rewriting which allows multiple forwarding servers to compact the return-path. SRS also provides an authentication mechanism to ensure that purported bounces are not arbitrarily forwarded.
SRS is documented at http://spf.pobox.com/srs.html and many points about the scheme are discussed at http://www.anarres.org/projects/srs/
For a better understanding of this code and how it functions, please read this document and run the interactive walkthrough in eg/simple.pl in this distribution. To run this from the build directory, type "make teach".