1. Go to this page and download the library: Download mlocati/tbfilters2gmail library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mlocati / tbfilters2gmail example snippets
// Parse the Thunderbird filters
$filters = \TBF2GM\MsgFilterRulesDatParser::fromFile('path/to/key.json')->parse();
// Initialize the Google API Client
$client = new \Google\Client();
$client->setAuthConfig('path/to/key.json');
$client->setScopes([\Google_Service_Gmail::GMAIL_LABELS, \Google_Service_Gmail::GMAIL_SETTINGS_BASIC]);
$client->setSubject('[email protected]');
// Create the Gmail filters
$writer = new \TBF2GM\Gmail\FilterWriter($client);
$problems = $writer->ensureFilters($filters);
// Let's print any error that may occur
foreach ($problems as $problemIndex => $problem) {
echo 'Problem ', $problemIndex + 1, (string) $problem, "\n";
}
$service = new \Google_Service_Gmail($client);
// Delete all the existing Gmail filters
foreach ($service->users_settings_filters->listUsersSettingsFilters('me')->getFilter() as $filter) {
$service->users_settings_filters->delete('me', $filter->getId());
}
// Delete all the existing Gmail folders
foreach ($service->users_labels->listUsersLabels('me') as $label) {
if ($label->getType() === 'user') {
$service->users_labels->delete('me', $label->getId());
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.