Anti spam script

require ["fileinto", "body", "imap4flags", "regex", "envelope", "spamtest", "relational", "comparator-i;ascii-numeric", "fileinto", "imap4flags"];

# Check for spam score
if allof (spamtest :value "ge" :comparator "i;ascii-numeric" "5") {
    fileinto "Spam";
    stop;
}

# Check for suspicious subject lines
if header :regex "Subject" ["(?i)\\b(viagra|cialis|enlargement|\\$\\$\\$)\\b"] {
    fileinto "Spam";
    stop;
}

# Check for missing or suspicious From headers
if anyof (not exists "From",
          header :regex "From" "(?i)\\b(mailer-daemon|postmaster)@") {
    fileinto "Spam";
    stop;
}

# Check for suspicious content in the body
if body :raw :contains ["click here", "limited time offer", "act now", "congratulations", "you've won"] {
    fileinto "Spam";
    stop;
}

# Check for Authentication-Results header
if header :contains "Authentication-Results" ["dkim=fail", "spf=fail", "dmarc=fail"] {
    fileinto "Spam";
    stop;
}

# If none of the above conditions are met, keep the message in the inbox
keep;