a Reasonably Uncomplicated Mail-server, Bundled with Lots of Extensions

Rumble - Simple Lua Examples

These examples shows some basic usage of the Rumble Lua API.
For more advanced scripting, check out the RumbleLua source code.



Checks if a client is blacklisted by any of the defined DNSBL services:

Blacklists = {

function checkBlacklist(session)
     -- Chop the IP into four digits
    local a,b,c,d = string.match(session.address, "(%d+)%.(%d+)%.(%d+)%.(%d+)")

    for k, host in pairs(Blacklists) do
        -- Make a reverse lookup address
        local reverse = string.format("%d.%d.%d.%d.%s", d,c,b,a,host)
        -- Check the blacklist
        local blacklisted = network.getHostByName(reverse);

        if (blacklisted) then
            session:send("You're blacklisted!\r\n");
            return "failure"; -- This causes the connection to close.

-- Hook our function to all incoming SMTP requests.
if (Rumble.setHook(checkBlacklist, "smtp", "accept")) then
    print("Blacklist activated!");