Git Product home page Git Product logo

emailrules's Introduction

Email rules

Requirements

  • Python 3.9 or higher
  • Virtual Environment
  • Google Account: You'll need a Google account to access the Gmail API.
  • Google Cloud Platform (GCP) Account: You need to have a GCP account to create a project and enable the Gmail API.

Installation

  1. Clone the repository:

    git clone [email protected]:sarathak/emailrules.git
  2. Navigate to the project directory:

    cd <project_directory>
    
  3. Create a virtual environment:

    python3 -m venv venv
  4. Activate the virtual environment:

    source venv/bin/activate
  5. Install project dependencies:

    pip install -r requirements.txt
    
    

Setup Instructions

Follow these steps to set up Gmail API:

1. Create a Project on Google Cloud Platform (GCP)

  1. Go to the Google Cloud Console.
  2. Click on the project selector dropdown and create a new project.
  3. Give your project a name and click Create.

2. Enable the Gmail API

  1. In the Google Cloud Console, navigate to the APIs & Services > Library page.
  2. Search for "Gmail API" and click on it.
  3. Click the Enable button.

3. Set up OAuth 2.0 Credentials

  1. In the Google Cloud Console, navigate to the APIs & Services > Credentials page.
  2. Click on Create Credentials > OAuth client ID.
  3. Select "Desktop app" as the application type.
  4. Give your OAuth client a name.
  5. Click Create.
  6. After creation, click on the OAuth client you just created from the list.
  7. Download credential file and putin to project directory as credentials.json

Run application

1. Fetch emails from api and store in database:

python fetch_emails.py

2. Execute rules

  1. Create rules as rules.json in project directory:
    [
       {
          "description": "Rule 1",
          "conditions": "all",
          "properties": [
             {
                "field": "from",
                "predicate": "contains",
                "value": "[email protected]"
             }
          ],
          "actions": [
             {
                "operation": "move",
                "destination": "bin"
             }
          ]
       }
    ]
    
  2. Execute script file
    python execute_rules.py

Run Unit tests

python tests.py

emailrules's People

Contributors

sarathak avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.