local kumo = require ‘kumo’ local dkim_sign = require ‘policy-extras.dkim_sign’ local shaping = require ‘policy-extras.shaping’ local queue_module = require ‘policy-extras.queue’ kumo.on(‘http_server_validate_auth_basic’, function(user, password) print(“KUMO AUTH DEBUG: user=“..tostring(user)..“, password=“..tostring(password)) return true end) local queue_helper = queue_module:setup { ‘/opt/kumomta/etc/policy/queues.toml’ } local dkim_signer = dkim_sign:setup { ‘/opt/kumomta/etc/policy/dkim_data.toml’ } local shaper = shaping:setup_with_automation { publish = { ‘http://127.0.0.1:8008’ }, subscribe = { ‘http://127.0.0.1:8008’ }, extra_files = { ‘/opt/kumomta/share/policy-extras/shaping.toml’, ‘/opt/kumomta/share/community/shaping.toml’, }, } kumo.on(‘get_egress_pool’, function(domain, tenant, campaign) local pool_name = tenant or ‘unspecified’ return pool_name end) local TENANT_PARAMS = { TenantOne = { max_age = ‘5 minutes’, }, } kumo.on(‘get_queue_config’, function(domain, tenant, campaign) local params = { max_age = ‘5 minutes’, retry_interval = ‘10 minutes’, max_retry_interval = ‘100 minutes’, egress_pool = tenant or ‘unspecified’, } utils.merge_into(TENANT_PARAMS[tenant] or {}, params) return kumo.make_queue_config(params) end) kumo.on(‘configure_message’, function(msg) msg:set_trace(true) end) kumo.on(‘init’, function() kumo.set_diagnostic_log_filter(“policy=debug,kumod=info”) kumo.configure_local_logs { log_dir = ‘/var/log/kumomta’, max_segment_duration = ‘1 minute’, headers = { ‘Subject’, ‘X-Customer-ID’ }, per_record = { Bounce = { template = [[Bounce! id={{ id }}, from={{ sender }} code={{ code }} age={{ timestamp - created }}]], }, }, } kumo.configure_bounce_classifier { files = { ‘/opt/kumomta/share/bounce_classifier/iana.toml’, }, } kumo.start_esmtp_listener { listen = ‘0.0.0.0:2525’, hostname = ‘me-83.gm1.sysenvmail.net’, relay_hosts = { “127.0.0.1", “::1”, “ip1", “ip2” }, } kumo.start_http_listener { listen = ‘0.0.0.0:8000’, trusted_hosts = { ‘0.0.0.0/0’ }, } kumo.define_spool { name = ‘data’, path = ‘/var/spool/kumomta/data’ } kumo.define_spool { name = ‘meta’, path = ‘/var/spool/kumomta/meta’ } end) kumo.on(‘smtp_server_message_received’, function(msg) local failed = msg:check_fix_conformance( ‘NON_CANONICAL_LINE_ENDINGS’, ‘’ ) if failed then kumo.reject(552, string.format(‘5.6.0 %s’, failed)) end queue_helper:apply(msg) dkim_signer(msg) end) kumo.on(‘http_message_generated’, function(msg) queue_helper:apply(msg) dkim_signer(msg) end)