SRS

From Halon, SMTP software for hosting providers
Jump to: navigation, search
The implementation code is available in our code repository.

The Halon SMTP software can implement a Mail::SRS compatible sender rewrite scheme using HSL.

Forward rewriting

In the pre-delivery (queue) script you should rewrite the $sender to be a part of the local-part of your SRS domain.

include "file:1"// SRS

// SRS for forwarded (lookup-mx transport) email
if ($transportid == "mailtransport:2" and $sender != "" and strtolower($sender[0:5]) != "srs0=")
    
SetSender(SRS_forward($sender"srs.example.com",  ["secret" => "mysecret"])); 

Reverse rewriting

Depending on where you expect to receive the SRS bounces (inbound or outbound listeners) you need to implement the following scripts in the relevant RCPT flow and/or the DATA flow, however the concept is the same for both cases.

This example is for the RCPT flow, were SRS recipient addresses should be accepted since normal recipient filtering will not work for these.

if ($sender == "" and $recipient[0:5] == "srs0=")
    
Accept(); 

This example is for the DATA flow, where the SRS domain should be rewritten back to the original domain.

include "file:1"// SRS

if ($recipientdomain == "srs.example.com") {
    
$opts = ["secret" => "mysecret"];
    
$srs SRS_reverse($recipient$opts);
    if (
$srs) {
        
SetRecipient($srs);
        
// SetMailTransport("mailtransport:1");
        // SetHeader("To", $srs);
    
} else {
        
Reject("Invalid SRS");
    }