The implementation code is available in our code repository.
The Halon platform can implement a Mail::SRS compatible sender rewrite scheme using HSL.
Forward rewriting
To enable SRS for a specific transport (e.g. outbound) you should rewrite the $sender to be a part of the local-part of your SRS domain. Open up the pre-delivery (queue) script under the Configuration -> Email engine -> Code editor page.
You will need to change so $transportid matches the correct lookup-mx transport for your cluster. You should also change the SRS domain and the secret string.
import { SRS_forward } from "srs"; // SRS file from our code repository
// SRS for forwarded (lookup-mx transport) email
if ($transportid == "mailtransport:2" and $sender != "" and strtolower($senderlocalpart[0:5]) != "srs0=")
SetSender(["localpart" => SRS_forward($senderlocalpart, $senderdomain, ["secret" => "mysecret"]), "domain" => "srs.example.com"]);
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 TO context and/or the DATA context, however the concept is the same for both cases.
This example is for the RCPT TO context, were SRS recipient addresses should be accepted since normal recipient filtering will not work for these.
if ($sender == "" and $recipientlocalpart[0:5] == "srs0=")
Accept();
This example is for the DATA context, where the SRS domain should be rewritten back to the original domain.
import { SRS_reverse } from "srs"; // SRS file from our code repository
if ($recipientdomain == "srs.example.com") {
$opts = ["secret" => "mysecret"];
$srs = SRS_reverse($recipientlocalpart, $opts);
if ($srs) {
SetRecipient($srs);
SetHeader("To", $srs["localpart"] . "@" . $srs["domain"]);
// SetMailTransport("mailtransport:1");
} else {
Reject("Invalid SRS");
}
}
Comments
0 comments
Article is closed for comments.