spam = odkim.get_header(ctx, "X-Spam-Status", 0) if spam == nil then odkim.stats(ctx, "spam", "-1") elseif string.sub(spam, 1, 3) == " No" then odkim.stats(ctx, "spam", "0") elseif string.sub(spam, 1, 4) == " Yes" then odkim.stats(ctx, "spam", "1") else odkim.stats(ctx, "spam", "-1") end n = 0 done = 0 found = 0 while (done == 0) do ares = odkim.get_header(ctx, "Authentication-Results", n) if ares == nil then done = 1 else spf = string.find(ares, "spf=", 1, true) if spf ~= nil then done = 1 found = 1 if string.find(ares, "spf=pass", 1, true) ~= nil then odkim.stats(ctx, "spf", "1") elseif string.find(ares, "spf=fail", 1, true) ~= nil then odkim.stats(ctx, "spf", "0") else odkim.stats(ctx, "spf", "-1") end if string.find(ares, "sender-id=pass", 1, true) ~= nil then odkim.stats(ctx, "senderid", "1") elseif string.find(ares, "sender-id=fail", 1, true) ~= nil then odkim.stats(ctx, "senderid", "0") else odkim.stats(ctx, "senderid", "-1") end end end n = n + 1 end if found == 0 then odkim.stats(ctx, "spf", "-1") odkim.stats(ctx, "senderid", "-1") end odkim.stats(ctx, "rcpts", tostring(odkim.rcpt_count(ctx)))