Created
February 11, 2024 16:51
-
-
Save fatalbanana/9e97b65650de943bab2eee1a72dce55c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- /etc/rspamd/rspamd.local.lua | |
local lua_maps = require 'lua_maps' | |
local rspamd_util = require 'rspamd_util' | |
local mail_to_allowed_user_map = rspamd_config:add_map{ | |
type = "map", | |
url = '/etc/rspamd/mail_to_allowed_user.map', | |
} | |
rspamd_config.ANTISPOOF = { | |
callback = function(task) | |
local user = task:get_user() | |
if not user then return end | |
local from = task:get_from('smtp') | |
if not from then return end | |
local mfrom = task:get_from('mime') | |
if not mfrom then | |
return true, 'no mime from' | |
end | |
if not rspamd_util.strequal_caseless(mfrom[1].addr, from[1].addr) then | |
return true, 'mime/smtp from mismatch' | |
end | |
if rspamd_util.strequal_caseless(user, from[1].addr) then | |
return false -- username matches from | |
end | |
if rspamd_util.strequal_caseless(mail_to_allowed_user_map:get_key(from[1].addr) or '', user) then | |
return false -- user is allowed to use this address | |
end | |
return true, string.format('%s not allowed to send mail as %s', user, from[1].addr) | |
end, | |
score = 30.0, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment