6

In the past I handled email filtering using Mail.app's Rules. I want to move my filters out of Mail.app and into another solution, such as a centrally-organized IMAP + procmail setup.

Is it possible to export apple mail.app rules for use with procmail?

If not for procmail per se, how about exporting to other formats that might be an easier intermediary between Mail.app and procmail?

1 Answer 1

5
+50

You can find them in plist format (just an xml flavor) in:

~/Library/Mail/V2/MailData/MessageRules.plist

You can write a script in the language of your choice to parse this file and produce rules suitable to procmail.

Here is a python draft:

#!/usr/bin/env python

import plistlib

pl = plistlib.readPlist('/Users/<user>/Library/Mail/V2/MailData/SyncedRules.plist')

for rule in pl:
    print
    print ':0:'
    mbox = ''
    for key in rule:
        if key == 'Criteria':
            for c in rule[key]:
                print '^%s:.*%s' % (c['Header'], c['Expression'])
        if key == 'CopyToMailbox':
            mbox = rule[key]
    print mbox
1
  • 1
    I'm looking for more specifics, i.e. links to example scripts that do this, AND / OR for email apps that correctly import Mail.app rules.
    – gosmond
    Oct 25, 2013 at 3:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .