The MTA for large-scale email services

Halon consolidates your email infrastructure, reducing risk and complexity. Halon makes email infrastructure scalable, simple to manage, rich in functionality and easy to evolve.

if (!$senderip) {
    SetProtocol("smtp"); // Use SMTP for locally generated DSNs
    Try();
}
// Use a more robust lookup like https://wiki.halon.io/API_calls
$route = cache ["ttl" => 3600] http("$apiurl/route", [], [$recipientdomain]);
$route = json_decode($route);
if (!is_array($route))
    Reschedule(3600, ["reason" => "Invalid route", "increment_retry" => false]);
SetDestination($route["storage"]);
SetProtocol("lmtp");
if (GetMetaData()["spam"] == "yes") {
    // Bulk IP
    SetSourceIP("netaddr:4");
} else {
    // Source hash
    $addrs = ["netaddr:1", "netaddr:2", "netaddr:3"];
    $sourcehash = number("0x".md5($senderdomain)[0:6]);
    SetSourceIP($addrs[$sourcehash % count($addrs)]);
}
$ptr = cache ["ttl" => 3600] dnsptr($sourceip, ["extended_result" => true]);
if (isset($ptr["result"][0]))
    SetHELO($ptr["result"][0]); 
// In the post-delivery script
if ($errorcode >= 400)
    rate("delivery-failures", $senderdomain, 1000, 3600);

// In the MAIL FROM script
if (rate("delivery-failures", $senderdomain, 0, 3600) > 999)
    Defer("$senderdomain has more than 1000 failed deliveries during the last hour");
// Per-domain DKIM signing using external database
function Deliver() {
    // Override the deliver function
    global $apiurl, $senderdomain;
    // Use a more robust lookup like https://wiki.halon.io/API_calls
    $dkim = cache ["ttl" => 86400, "size"=> 32768, "ttl_override" => ["" => 60]]
        http("$apiurl/dkim/$1", ["timeout" => 10], [$senderdomain]);
    $dkim = json_decode($dkim);
    if (is_array($dkim))
        DKIMSign($dkim["selector"], $dkim["domain"], $dkim["rsakey"]);
    builtin Deliver();
}