mirror of
https://github.com/KumoCorp/kumomta.git
synced 2026-11-18 16:07:21 +00:00
Nobody runs it and it is not as good as RocksDB. I want to remove it in the future so that users don't unwittingly deploy a poor configuration. We now log errors on startup to help surface configuration that will need attention, but we don't block startup.
81 lines
2.0 KiB
Lua
81 lines
2.0 KiB
Lua
-- This config acts as a sink that capture all received mail into a maildir
|
|
local kumo = require 'kumo'
|
|
package.path = '../../assets/?.lua;' .. package.path
|
|
local utils = require 'policy-extras.policy_utils'
|
|
|
|
local TEST_DIR = os.getenv 'KUMOD_TEST_DIR'
|
|
|
|
kumo.on('init', function()
|
|
kumo.configure_accounting_db_path ':memory:'
|
|
|
|
kumo.start_esmtp_listener {
|
|
listen = '127.0.0.1:0',
|
|
relay_hosts = { '0.0.0.0/0' },
|
|
}
|
|
|
|
kumo.configure_local_logs {
|
|
log_dir = TEST_DIR .. '/logs',
|
|
max_segment_duration = '1s',
|
|
}
|
|
|
|
kumo.define_spool {
|
|
kind = 'RocksDB',
|
|
name = 'data',
|
|
path = TEST_DIR .. '/data-spool',
|
|
}
|
|
|
|
kumo.define_spool {
|
|
kind = 'RocksDB',
|
|
name = 'meta',
|
|
path = TEST_DIR .. '/meta-spool',
|
|
}
|
|
|
|
zones = {
|
|
[[
|
|
$ORIGIN localhost.
|
|
@ 600 TXT "v=spf1 all"
|
|
denied TXT "v=spf1 -all exp=explain._spf.localhost."
|
|
allowed TXT "v=spf1 +all"
|
|
explain._spf TXT "helo=%{h}"
|
|
]],
|
|
}
|
|
kumo.dns.configure_test_resolver(zones)
|
|
end)
|
|
|
|
kumo.on('get_queue_config', function(_domain, _tenant, _campaign)
|
|
return kumo.make_queue_config {
|
|
protocol = {
|
|
maildir_path = TEST_DIR .. '/maildir',
|
|
},
|
|
}
|
|
end)
|
|
|
|
kumo.on('smtp_server_ehlo', function(domain, conn_meta)
|
|
local result = kumo.spf.check_host(domain, conn_meta, nil)
|
|
print('SPF-ehlo', kumo.json_encode_pretty(result))
|
|
if result.disposition == 'fail' then
|
|
kumo.reject(550, '5.7.1 SPF EHLO check failed ' .. result.result.reason)
|
|
end
|
|
end)
|
|
|
|
kumo.on('smtp_server_mail_from', function(sender, conn_meta)
|
|
local result =
|
|
kumo.spf.check_host(sender.domain, conn_meta, tostring(sender))
|
|
print('SPF-mail-from', kumo.json_encode_pretty(result))
|
|
if result.disposition == 'fail' then
|
|
kumo.reject(
|
|
550,
|
|
'5.7.1 SPF MAIL FROM check failed ' .. result.result.reason
|
|
)
|
|
end
|
|
end)
|
|
|
|
kumo.on('smtp_server_message_received', function(msg, conn_meta)
|
|
msg:set_meta('queue', 'maildir')
|
|
local result = kumo.spf.check_msg(msg)
|
|
local results = {
|
|
result.result,
|
|
}
|
|
msg:add_authentication_results(msg:get_meta 'hostname', results)
|
|
end)
|