Skip to content
Dolf Schimmel edited this page May 7, 2017 · 6 revisions

It's possible to write your own modules using Lua. You can do so by adding to the configuration:

[luaModule "something"]
enabled = true
script = ./lua/something.lua

Following the configuration above, it will register the module as lua-something internally.

This script outlines all the available calls that are available:


local testMsg = {
    _VERSION     = 'testMsg v1.0.0',
    _DESCRIPTION = 'This is a basic module that demonstrates the ClueGetter LUA functionality',
    _URL         = 'https://github.com/Freeaqingme/ClueGetter',
    _LICENSE     = '2-clause BSD license'
}

testMsg.milterCheck = function(message)
    print("Queue Id:", message:getQueueId())
    print("From:\t", message:getFrom())

    for i,v in pairs(message:getRcpt()) do
        print("Recipient:", v)
    end

    print("Headers:")
    for i,v in pairs(message:getHeaders()) do
        print("\t", v:getKey(), v:getValue())
    end

    print("Body:")
    print(message:getBody())

    return "REJECT", "We think it's spam!", 2.00
end

-- Retrieve & modify the SessionConfig object
testMsg.sessionConfigure = function(session)
    print(session:config("Dkim.Sign")) -- prints 'optional'
    print(session:config("Dkim.Sign", "required"))
    print(session:config("Dkim.Sign")) -- prints 'required'
end


return testMsg

Session Config

Each session carries a (partial) copy of the global configuration. This allows to override specific configuration settings on a per-session (or even per-message) basis. Currently, the following settings can be overridden through the session::config(<key>, [<value>]) call:

Key Value type Allowed values
Dkim.Sign string 'required', 'optional', 'none'
Greylisting.Enabled bool
Clone this wiki locally