Filtering Postini tagged mail with Sieve

The headers Postini’s anti-spam system adds to emails are quite hard to filter on, as you need to compare part of one header to part of another. Here’s a little snipped that works with dovecot 1.2’s sieve implementation. I don’t actually use this myself anymore, but I’m posting it here for anyone else struggling with the problem.

if not header :matches "X-pstn-addresses" "good)"
{
  # X-pstn-levels: (S: 0.00799/98.42547 CV:99.9000 FC:95.5390 LC:95.5390 R:95.9108 P:95.9108 M:97.0282 C:98.6951 )
  # X-pstn-settings: 3 (1.0000:1.0000) s cv gt3 gt2 gt1 r p m c
  if header :matches "X-pstn-levels" "(S: *.*/*"
  {
    set "score" "${1}";
    set "scoredp" "${2}";
    if header :matches "X-pstn-settings" "? (*:*.*) *"
    {
      set "threshold" "${3}";
      set "thresholddp" "${4}";

      if string :value "lt" "${score}" "${threshold}"
      {
        fileinto "postini";
        stop;
      }

    }
  }
}

As a quick note, my final solution was to add a much simpler header after using exim’s perl integration to parse the postini headers.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.