From 4b1814d9a000fd7c98d6c63eaa0bf1d9cdc5a242 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 29 Jun 2017 08:58:40 +0100 Subject: [PATCH] [Feature] Allow to check reply-to email --- src/plugins/lua/emails.lua | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/plugins/lua/emails.lua b/src/plugins/lua/emails.lua index 11535014a..3c3d103fd 100644 --- a/src/plugins/lua/emails.lua +++ b/src/plugins/lua/emails.lua @@ -104,7 +104,7 @@ end local function check_emails(task) local emails = task:get_emails() local checked = {} - if emails then + if emails and not rule.skip_body then for _,addr in ipairs(emails) do local to_check = string.format('%s@%s', addr:get_user(), addr:get_host()) local naddr = { @@ -123,6 +123,26 @@ local function check_emails(task) end end end + + for _,rule in ipairs(rules) do + if rule.check_replyto then + local function get_raw_header(task, name) + return ((task:get_header_full(name) or {})[1] or {})['raw'] + end + + local replyto = get_raw_header(task, 'Reply-To') + if not replyto then return false end + local rt = util.parse_mail_address(replyto) + + if rt and rt[1] then + rspamd_lua_utils.remove_email_aliases(rt[1]) + if not checked[rt[1].addr] then + check_email_rule(task, rule, rt[1]) + checked[rt[1].addr] = true + end + end + end + end end local opts = rspamd_config:get_all_opt('emails', 'rule') -- 2.39.5