Petrea Corneliu ┼×tefan
and 1 contributors


Mail::Google::Procmailrc - Perl module that allows easy conversion from Gmail mail filters to Procmail rules


  use Mail::Google::Procmailrc;
  my $o = Mail::Google::Procmailrc->new(<path-to-mail-folders>);
  $o->convert(<google-mail-filter-path>, <procmail-rules-output-path>);

or, you can use it with the helper script

  ./bin/google-to-procmailrc ./mailFilters.xml test-procmail.rc $HOME/somemail


You may want at some point, for some reason to export all your gmail mail rules as procmail filters.

If you use a mail setup involving OfflineIMAP fetching multiple folders(labels) from Google, you'll notice that there is a certain overhead involved.

That's because OfflineIMAP needs to tell the IMAP server, which messages it has, in order to retrieve only the ones that it doesn't, and then for each new message fetched it also needs to update the SQLite local dbs with the statuses of the new messages. And it has to do that for every folder(label). That highly depends on which labels you fetch with OfflineIMAP.

If you want to make the sync faster, you can consider only fetching the "[Gmail]/All Mail" folder or the "INBOX" folder, but then you still have to solve mail triage.

Procmail is quite good for mail triage, but the mailFilters.xml file that you can export from Gmail is not suited for use with Procmail AFAIK.

This module aims to solve that problem by converting mailFilters.xml to a set of procmail rules (effectively a procmailrc file).

Normally, you'd use the script that comes with this module to migrate your Gmail rules to procmail and then you can just maintain the procmail rules. At least that's how I(plan to) use it.


If you decide to use [Gmail]/All Mail as the folder you sync and then use procmail to run on it, you'll have to deal with the Spam (maybe spamassassin would help there).

From that point of view it's probably easier to just use INBOX.

Currently this module only has functionality for converting some of the gmail rules.


Exporting Gmail mail filters
Synchronization that OfflineIMAP does


Please report bugs using the queue.


Patches are welcome, either in the form of pull-requests on the github repo or in the form of patches on cpan's request tracker


Stefan Petrea, <>


Copyright (C) 2014 by Stefan Petrea

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.18.2 or, at your option, any later version of Perl 5 you may have available.