Any way to get more powerful rules for Mail.app?

Is there a way to enhance Mail.app with better rules?

What I'm missing most is regexps and the ability to group conditions and not only get "If all rules match" or If one rule match"

Alternatively is there a way to use apple-scripts as rules?

Note:

I'm not after Junk Mail Filtering


Solution 1:

There is no way I can think of to use AppleScript to filter messages directly, but I guess you could go the ugly route of redirecting "All Messages" to an AppleScript and then handling them from there back to Mail.app.

==== Update:

To give you a better idea of what I´m talking about, you´ll have to create a new rule with condition "All Messages" and execute an Applescript. For example to check for the subject, you´ll want something similar to this:

using terms from application "Mail"
    on perform mail action with messages theMessages for rule theRule
        tell application "Mail"

            repeat with eachMessage in theMessages
                set theSubject to subject of eachMessage

                if theSubject contains "test" then
                    -- do something here, like move message to a folder
                end if
            end repeat

        end tell
    end perform mail action with messages
end using terms from

Note that of course you could easily use a do shell script statement here to use whatever command line tool you want to compare the subject with a regexp, like if (do shell script "*your regexp that returns 'true' if matched*" ) is true … and so on.