/gmail2discord

Sends a message in Discord when your Gmail gets an email from a specified email address. Don't pay for Zapier because this is free.

Primary LanguagePythonMIT LicenseMIT

Gmail to Discord Notification Tool

This tool listens for incoming emails in a specified Gmail account and sends notifications to a Discord channel when new emails are received. It's designed to be used with the Heroku platform and can be scheduled to check for new emails at regular intervals.

Features

  • Automatically listens for incoming Gmail messages and posts to Discord.
  • Tracks processed messages to avoid duplicate notifications.
  • Parses email timestamps correctly, including handling time zones and "(UTC)" format issues.
  • Designed to work with Heroku's free tier, scheduled to run every 10 minutes.

Prerequisites

  • Google Cloud account with Gmail API enabled.
  • Heroku account with a Python environment.
  • A Discord Webhook URL to post the notifications to.

Setup Instructions

  1. Clone the repository:
  2. git clone https://github.com/yourusername/gmail-to-discord
  3. Set up Google Cloud:
    • Create a Google Cloud project and enable the Gmail API.
    • Download your credentials as credentials.json and place it in the project directory.
    • Run the authorization flow to generate the token.json file.

  4. Set up Heroku:
    • Create a new Heroku app:
    • heroku create
    • Deploy the app to Heroku:
    • git push heroku master
    • Add your Discord Webhook URL as a config variable in Heroku:
    • heroku config:set DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/your_webhook_url
  5. Run the app:
    • Schedule the script to run every 10 minutes using the Heroku Scheduler:
    • heroku addons:create scheduler:standard
    • Set up the job to run python3 gmail_to_discord.py every 10 minutes in the scheduler dashboard.

  6. View Logs:
    • To view logs and troubleshoot:
    • heroku logs --tail --app your_app_name

Important Notes

  • Ensure that your Google Cloud credentials and tokens are properly set up and stored securely.

License

This project is open-source and available under the MIT License.