소스 검색

[Feature] Remove + aliases from emails

tags/1.5.2
Vsevolod Stakhov 7 년 전
부모
커밋
c65fcbf100
1개의 변경된 파일71개의 추가작업 그리고 0개의 파일을 삭제
  1. 71
    0
      rules/misc.lua

+ 71
- 0
rules/misc.lua 파일 보기

@@ -830,3 +830,74 @@ rspamd_config.OMOGRAPH_URL = {
score = 5.0,
description = 'Url contains both latin and non-latin characters'
}

rspamd_config:register_symbol{
type = 'prefilter',
name = 'EMAIL_PLUS_ALIASES',
callback = function(task)
local function check_address(addr)
if addr.user then
local cap = string.match(addr.user, '^([^%+][^%+]*)%+.*$')
if cap then
return cap
end
end

return nil
end

local function set_addr(addr, new_user)
addr.user = new_user

if addr.domain then
addr.addr = string.format('%s@%s', addr.user, addr.domain)
else
addr.addr = string.format('%s@', addr.user)
end

if addr.name then
addr.raw = string.format('%s <%s>', addr.name, addr.addr)
else
addr.raw = string.format('<%s>', addr.addr)
end
end

local function check_from(type)
if task:has_from(type) then
local addr = task:get_from(type)[1]
local na = check_address(addr)
if na then
set_addr(addr, na)
task:set_from(type, addr)
end
end
end

check_from('smtp')
check_from('mime')

local function check_rcpt(type)
if task:has_recipients(type) then
local modified = false
local addrs = task:get_recipients(type)

for i,addr in ipairs(addrs) do
local na = check_address(addr)
if na then
set_addr(addr, na)
modified = true
end
end

if modified then
task:set_recipients(type, addrs)
end
end
end

check_rcpt('smtp')
check_rcpt('mime')
end,
priority = 150,
description = 'Removes plus aliases from the email',
}

Loading…
취소
저장