Download the PHP package mlocati/tbfilters2gmail without Composer
On this page you can find all versions of the php package mlocati/tbfilters2gmail. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mlocati/tbfilters2gmail
More information about mlocati/tbfilters2gmail
Files in mlocati/tbfilters2gmail
Package tbfilters2gmail
Short Description A PHP library that allows you to parse Thunderbird rule files (msgFilterRules.dat) and easily export them to Google Gmail filters
License MIT
Homepage https://github.com/mlocati/tbfilters2gmail
Informations about the package tbfilters2gmail
Thunderbird to Gmail library
This library helps you copying Thunderbird filters to Gmail.
Introduction
Thunderbird saves email filters in a file named msgFilterRules.dat
.
This library can read this file, and create automatically the required folders and filters in a Gmail account.
Requirements
Locate the msgFilterRules.dat
file
You need to know where Thunderbird saves the msgFilterRules.dat
file.
In order to do that, open Thunderbird and:
- show the menu (use the
ALT-F
keys) - under the
Tools
menu, chooseAccount Settings
- in the left list, choose the
Server Settings
item under the account name - in the right pane, you'll see the
Message Storage
section: the folder containing the filemsgFilterRules.dat
should be the one specified in theLocal Directory
field
Create a Gmail Service account
You need a Gmail service account in order to use this library. Here's the complete list of steps required to correctly create and configure it:
- create a Google project
- go to the Google Cloud Platform dashboard page
- create a new project
- enable the Gmail API
- go to the Google Cloud Platform dashboard page
- from the menu, choose APIs & Services → Library
- search for Gmail API and enable them for the project created above
- create a Service Account
- go to the Google Cloud Platform dashboard page
- from the menu, choose IAM & Admin → Service Accounts
- click the + Create service account button
- in the Step 1, enter any name/description you like
- in the Step 2, choose the Owner Role (Full access to all resources.)
- in the Step 3, you can leave the default (empty) values
- in the Service Account list, choose the Create key action for the newly created service account
- download the key in JSON format
- save the
.json
file in a secure location
- in the Service Account list, choose the Edit action for the newly created service account
- in the Service account status section, click the Show domain-wide delegation
- check the Enable G Suite Domain-wide Delegation option
- save
- grant the required OAuth scopes
- go to the Google Admin page
- from the menu, choose Security → API Controls
- in the Domain wide delegation section, click the Manage domain wide delegation link
- add a new API client
- in the Client ID field enter the number associated to the
client_id
key in the.json
file you downloaded above - you have to specify these OAuth scopes (here you can find all the available scopes):
https://www.googleapis.com/auth/gmail.labels
(required to manage the folders of the Gmail accounts)https://www.googleapis.com/auth/gmail.settings.basic
(required to manage the filters of the Gmail accounts)
- in the Client ID field enter the number associated to the
Sample usage
Let's assume that:
- you downloaded the JSON key for the service account to
path/to/key.json
- the Thunderbird filters files is available at
path/to/msgFilterRules.dat
- the email address of the Gmail account is
[email protected]
With the above data, you can copy the Thunderbird filters to Gmail with a few lines of code like these:
Ad this point, you should have the Thunderbird filters available in Gmail.
Known issues
- It seems it's not possible to create Gmail filters with rules like
begins with
,ends with
,is exactly
, ... Gmail filters always search for parts of the text. So, for example, a Tunderbird criteria likeIf the subject starts with "Some text"
will generate a Gmail filter likeIf the subject contains "Some text"
. - The "Stop Filter Execution" Tunderbird action is ignored (it seems there's no way to implement such feature in Gmail filters)
- It seems it's not possible to create Gmail filters with header-specific criterias
- Not every criteria/action has been implemented in this library. We implemented only the ones we actually needed.
How to delete all the Gmail filters and/or folders
If you want to test this library, you may need to delete all the existing Gmail filters and/or folders.
You can do that with this code (we assume that the $client
variable is initialized as described in the Sample usage section above)