You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. rspamd_config.TEST_RCPT = {
  2. callback = function(task)
  3. local l = {}
  4. local rcpts = task:get_recipients(1)
  5. if not rcpts then return end
  6. for _, r in ipairs(rcpts) do
  7. table.insert(l, r['addr'])
  8. end
  9. table.sort(l)
  10. local t = table.concat(l, ",")
  11. return true, t
  12. end
  13. }
  14. rspamd_config.TEST_HELO = {
  15. callback = function(task)
  16. local helo = task:get_helo()
  17. if not helo then return end
  18. return true, helo
  19. end
  20. }
  21. rspamd_config.TEST_HOSTNAME = {
  22. callback = function(task)
  23. local h = task:get_hostname()
  24. if not h then return end
  25. return true, h
  26. end
  27. }
  28. rspamd_config.TEST_SMTP_FROM = {
  29. callback = function(task)
  30. local f = task:get_from('smtp')
  31. if not (f and f[1] and f[1].addr) then return end
  32. return true, f[1].addr
  33. end
  34. }
  35. rspamd_config.TEST_MTA_TAG = {
  36. callback = function(task)
  37. local h = task:get_request_header('MTA-Tag')
  38. if not h then return end
  39. return true, tostring(h)
  40. end
  41. }
  42. rspamd_config.TEST_USER = {
  43. callback = function(task)
  44. local u = task:get_user()
  45. if not u then return end
  46. return true, u
  47. end
  48. }
  49. rspamd_config.TEST_QUEUEID = {
  50. callback = function(task)
  51. local q = task:get_queue_id()
  52. if not q then return end
  53. return true, q
  54. end
  55. }
  56. rspamd_config.TEST_IPADDR = {
  57. callback = function(task)
  58. local i = task:get_from_ip()
  59. if not (i and i:is_valid()) then return end
  60. return true, tostring(i)
  61. end
  62. }
  63. rspamd_config.FORCE_DEFER = {
  64. callback = function(task)
  65. local f = task:get_from('smtp')
  66. if not (f and f[1] and f[1].addr) then return end
  67. if f[1].addr == "defer@example.org" then
  68. task:set_pre_result('soft reject', 'Try much later')
  69. return true
  70. end
  71. end
  72. }