]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Allow to check reply-to email
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 29 Jun 2017 07:58:40 +0000 (08:58 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 29 Jun 2017 07:59:21 +0000 (08:59 +0100)
src/plugins/lua/emails.lua

index 11535014a5801daf1696c394410802055f441328..3c3d103fdf54798d75091868c0e7807cf86683b0 100644 (file)
@@ -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')