Skip to content

carlosrabelo/grc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GRC - GMail Rules Creator

This project provides a tool to generate XML files for configuring Gmail filters based on a YAML input file. It allows for easy management and customization of mail filters while adhering to a specified structure.

Features

  • Accepts a YAML input file containing author details, default values, and filter configurations.
  • Supports a broad set of Gmail filter criteria (from, to, subject, query, attachments, etc.) and actions (archive, mark as read, star, forward, trash, labels and more).
  • Automatically applies default values to boolean actions when optional parameters are omitted.
  • Validates required author and filter fields before generating the XML.
  • Outputs a formatted XML file compatible with Gmail's filter configuration.

Project Structure

project/
├── resources/
│   └── example.yaml  # Example YAML file for testing
├── main.go           # Main source code file
├── Makefile          # Build and execution commands
├── .gitignore        # Ignored files and directories
└── README.md         # Project documentation

Available filter options

Each filter entry may include any combination of the following criteria:

  • from, to, subject, hasTheWord, doesNotHaveTheWord, list, query, hasAttachment

Actions that can be applied:

  • label, smartLabel, forwardTo
  • Boolean flags: shouldArchive, shouldMarkAsRead, shouldStar, shouldNeverSpam, shouldAlwaysMarkAsImportant, shouldNeverMarkAsImportant, shouldTrash

All boolean flags inherit their defaults from the default section when omitted. Every filter must declare at least one condition and one action.

Prerequisites

  • Go (Golang) 1.20 or later

Getting Started

1. Clone the repository

git clone <repository-url>
cd project

2. Prepare your YAML input file

Ensure that a YAML file with the required structure exists in the resources/ directory. You can use the provided example.yaml as a reference:

author:
  name: "John Doe"
  email: "[email protected]"

default:
  shouldArchive: true
  shouldMarkAsRead: false
  shouldStar: false
  shouldNeverSpam: true
  shouldAlwaysMarkAsImportant: false
  shouldNeverMarkAsImportant: false
  shouldTrash: false

filters:
  - from: "[email protected]"
    label: "Work"
  - to: "[email protected]"
    subject: "[Ticket]"
    hasAttachment: true
    label: "Support"
    shouldMarkAsRead: true
    shouldStar: true
  - query: "list:announcements.example.com"
    label: "Announcements"
    forwardTo: "[email protected]"
    shouldArchive: false
    shouldAlwaysMarkAsImportant: true

3. Build the project

Run the following command to compile the binary:

make build

4. Generate XML

Use the provided generate-sample Makefile target to create the XML file for the bundled example:

make generate-sample

This command compiles the program (when needed) and generates an XML file next to the YAML input (for the example it will be resources/example.xml).

5. Clean up

To remove generated files, use:

make clean

Usage

Run the compiled binary directly with a specified YAML file as input:

./build/grc resources/example.yaml

The output XML file will be saved in the same directory as the input YAML file, with the .xml extension. Override the name with the -output flag when you need a different location.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

About

Gmail Rules Creator

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published