Petrea Corneliu Ştefan > Mail-Google-Procmailrc-0.022 > Mail::Google::Procmailrc

Download:
Mail-Google-Procmailrc-0.022.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  1
View/Report Bugs
Module Version: 0.022   Source  

NAME ^

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

SYNOPSIS ^

  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

  google-to-procmailrc --input ./mailFilters.xml --output test-procmail.rc --mdir-path $HOME/somemail

DESCRIPTION ^

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.

METHODS ^

new($folders_path, $archive_dir, $trash_dir)

The constructor receives $folders_path which is the directory where all the mail folders resulting from the triage will be placed. The other two, archive and trash will be used with the same role as archiving e-mail, and the [Gmail]/Trash folder.

generate_create_dirs_script

This method will generate a script called create.sh . This script will create all the folders. Afterwards, there will be a one-to-one mapping between the labels present in your mailFilters.xml and folders on disk. They will be empty, but after running procmail they will be filled with the mails that correspond to them.

generate_rule_catchall()

Returns a catchall rule for the inbox

convert($input,$output)

This method takes the input XML and uses "adapt" to convert it to the procmail rules file.

adapt($x)

Receives as parameter a nested hash structure generated by XML::Fast from parsing the mailFilters.xml file, then traverses that structure. This is where the conversion happens.

collect_labels

Collects labels found so that create.sh can be generated. See the "generate_create_dirs_script" method for details.

compute_flag()

Generates appropriate flag if the rule chain has not ended yet.

rule_from

Generic "From:" rule conversion.

apply_debug_info()

Adds a X-Procmail-Debug header to the e-mail so you can trace back to the rule that matched it.

This is triggered through the --debug parameter.

rule_to

Generic "To:" rule conversion.

rule_archive

Uses the "rule_to" , "rule_from", "rule_subject", "rule_body" methods to archive e-mail.

rule_trash

Same as rule_archive but for trash.

check_multiple_rules($h)

Checks if there are multiple locations where the mail should be placed. Stores whether there are multiple such places and how many of them are. This will later be used in order to

escape_fields

Escape the field values used for the procmail filters

adapt_rule($h)

Converts a Gmail mail filter to procmail rules. Returns a string with the procmail rule.

NOTES ^

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.

SEE ALSO ^

BUGS ^

Please report bugs using the rt.cpan.org queue.

PATCHES ^

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

AUTHOR ^

Stefan Petrea, <stefan@garage-coding.com>

COPYRIGHT AND LICENSE ^

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.10.0 or, at your option, any later version of Perl 5 you may have available.

syntax highlighting: