# Gmail Filter Builder [![Build Status](https://travis-ci.org/opdavies/gmail-filter-builder.svg?branch=master)](https://travis-ci.org/opdavies/gmail-filter-builder) This library allows you to define Gmail filters in PHP, and then generate XML that you can import into Gmail's filter settings Inspired by https://github.com/antifuchs/gmail-britta. ## Installation and Basic Usage ### Step 1: Require the Library ```bash composer require opdavies/gmail-filter-builder ``` ### Step 2: Create Your Filters File Create a `filters.php` file that returns an array of `Filter` objects. For example: ```php from('foo@example.com') ->to($myAddresses) ->trash(), ]; ``` In this example, the addresses are returned as an array from `~/.gmail-filters/my-addresses.php` and then used as a condition in the filter. ## Filter Examples ```php // If an email is from a certain address, add a label. Filter::create() ->from('john@example.com') ->label('Something'); ``` ## References - [Search operators you can use with Gmail](https://support.google.com/mail/answer/7190?hl=en)