A tool for managing your GMail filters that has two tricks:
- You can manage your filters as a YAML file, which has substantially less markup than the XML export from GMail
- You can specify multiple labels for a filter, and
gmailfilters
will automatically expand that into multiple filters, each applying a single label.
For example, if you have:
- from: [email protected]
label: gmail awesome redhat
You will get, in your generated XML, something like:
<entry>
<title>Mail Filter</title>
<category term="filter"/>
<updated>2017-06-26T15:28:31.018961</updated>
<content/>
<app:property name="from" value="[email protected]"/>
<app:property name="label" value="gmail"/>
</entry>
<entry>
<title>Mail Filter</title>
<category term="filter"/>
<updated>2017-06-26T15:28:31.018961</updated>
<content/>
<app:property name="from" value="[email protected]"/>
<app:property name="label" value="awesome"/>
</entry>
<entry>
<title>Mail Filter</title>
<category term="filter"/>
<updated>2017-06-26T15:28:31.018961</updated>
<content/>
<app:property name="from" value="[email protected]"/>
<app:property name="label" value="redhat"/>
</entry>
Export your GMail filters to XML:
- Go to Settings -> Filters and Blocked Addresses
- At the bottom of the filter list, click "All" to select all filters
- Click the "Export" button to save your filters
Convert your filters to YAML:
gmailfilters --fromxml mailFilters.xml -o mailFilters.yml
Make changes to your YAML document (e.g. mailFilters.yml
).
Convert your filters to XML:
gmailfilters --toxml mailFitlers.yml -o mailFilters.xml
Delete your existing filters in GMail:
- Go to Settings -> Filters and Blocked Addresses
- At the bottom of the filter list, click "All" to select all filters
- Select "Delete" to delete the filters.
Import your filters into GMail:
- Go to Settings -> Filters and Blocked Addresses
- At the bottom of the filter list, select "Import filters"
- Select "Choose File" and navigate to your generated XML filters.
- Select "Open file"
- Scroll to the bottom of the list of filters and select "Create filters"