Mail Filters

Global Scripts

Spam Filter

#
# Move spam mails into to the designated junk folder
# Flag message as Spam
# The folder is create if it doesn't exist already.
#
require [ "fileinto", "imap4flags" ];
if header :contains "X-Spam-Flag" "YES" {
    fileinto :create :flags "\\Junk", "\\Seen" "Spam";
    stop;
}

Mailing Lists

#
# Move Mailing-List Messages in to its own folder.
# The folder is create if it doesn't exist already.
#
require [ "variables", "fileinto", "mailbox" ];
if anyof (  header "Precedence" "list",
            header "Precedence" "bulk",
            exists "List-Id" )
{
    # Mailman lists
    if header :matches "X-BeenThere" "*<*@*"
    {
        fileinto :create "Lists.${2}";
        stop;
    }
    # Other lists
    elseif header :matches "List-ID" "*<*@*"
    {
        fileinto :create "Lists.${2}";
        stop;
    }
    # Unknown
    else
    {
        fileinto :create "Lists";
    }
}

Testing Your Sieve Scripts