Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

23 Commits

Folders and files

Repository files navigation

πŸ“§βž‘οΈπŸ“± Gmail to Telegram Notifier

GitHub Actions Status Python

A multi-account Gmail monitoring system that automatically forwards email notifications to Telegram. Monitor up to 3 Gmail accounts simultaneously with real-time notifications, account identification, and automatic email processing.

✨ Key Features

  • 🏒 Multi-Account Support - Monitor 3 Gmail accounts simultaneously
  • ⚑ Real-Time Notifications - Instant Telegram alerts for new emails
  • 🎯 Account Identification - Know exactly which Gmail account received the email
  • πŸ”„ Automatic Processing - Auto-mark emails as read after notification
  • πŸ” Enterprise Security - OAuth2 authentication with encrypted GitHub Secrets
  • πŸ’° 100% Free - Runs on GitHub Actions (no servers required)
  • ⏰ 24/7 Monitoring - Checks emails every 5 minutes automatically
  • πŸ›‘οΈ Privacy Focused - No email content stored, only notifications sent

πŸš€ Quick Start

Prerequisites

  • Gmail accounts (up to 3)
  • Telegram Bot Token
  • GitHub account
  • Basic knowledge of GitHub Secrets

πŸ“Έ Screenshots & Demo

1. πŸ“± Telegram Notifications

Multi-Account Email Notifications with Account Identification:

Multi-Account Email Notifications with Account Identification

Snippet: New login detected from unknown device...

2. 🟒 GitHub Actions Dashboard

Automated Workflow Runs (Every 5 Minutes): alt text

Successful workflow runs showing 24/7 monitoring with perfect uptime

3. πŸ” GitHub Secrets Configuration

Secure Credential Management:

alt text

All 8 secrets properly configured for multi-account authentication

4. πŸ“Š Performance Metrics

System Performance Dashboard:

πŸ“Š Last 24 Hours Performance:
─────────────────────────────
βœ… Uptime: 100%
βœ… Successful Runs: 288/288
βœ… Emails Processed: 47
βœ… Notifications Sent: 47
βœ… Average Response Time: 6 seconds
βœ… Token Refreshes: 12 (all successful)

πŸ† Multi-Account Status:
─────────────────────────
πŸ“§ ajit.info999@gmail.com: βœ… Active (15 emails today)
πŸ“§ ajitbro111@gmail.com: βœ… Active (18 emails today)  
πŸ“§ 421mrdark@gmail.com: βœ… Active (14 emails today)

πŸ› οΈ Setup Instructions

Step 1: Clone Repository

git clone https://github.com/ajit421/gmail-telegram-notifier.git
cd gmail-telegram-notifier

Step 2: Gmail API Setup

  1. Go to Google Cloud Console: https://console.cloud.google.com/
  2. Create New Project or select existing
  3. Enable Gmail API:
    • Navigate to "APIs & Services" β†’ "Library"
    • Search for "Gmail API" and enable it
  4. Create Credentials:
    • Go to "APIs & Services" β†’ "Credentials"
    • Click "Create Credentials" β†’ "OAuth 2.0 Client IDs"
    • Choose "Desktop application"
    • Download credentials JSON file

Step 3: Telegram Bot Setup

  1. Create Bot: Message @BotFather on Telegram
  2. Send: /newbot
  3. Choose bot name and username
  4. Save Bot Token: You'll receive a token like 1234567890:ABCdefGHIjklMNOpqrsTUVwxyZ
  5. Get Chat ID:
    • Start conversation with your bot
    • Send any message
    • Visit: https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates
    • Find your chat ID in the response

Step 4: Local Authentication (For Each Gmail Account)

For Account 1 (Main):

python auth_main.py

For Account 2 (AjitBro):

python auth_ajitbro.py

For Account 3 (MrDark):

python auth_mrdark.py

Follow browser prompts to authenticate each account

Step 5: GitHub Secrets Configuration

Add these 8 secrets in your GitHub repository: Settings β†’ Secrets and variables β†’ Actions β†’ New repository secret

Secret Name Description Example Value
TELEGRAM_BOT_TOKEN Your Telegram bot token 1234567890:ABCdefGHI...
TELEGRAM_CHAT_ID Your Telegram chat ID 123456789
GOOGLE_CREDENTIALS OAuth credentials JSON {"installed":{"client_id":"..."}}
GOOGLE_TOKEN Main account token {"token":"yC29.a0AQQ..."}}
GOOGLE_CREDENTIALS_AJITBRO Same as GOOGLE_CREDENTIALS {"installed":{"client_id":"..."}}
GOOGLE_TOKEN_AJITBRO Second account token {"token":"yB29.a0AQ..."}}
GOOGLE_CREDENTIALS_MRDARK Same as GOOGLE_CREDENTIALS {"installed":{"client_id":"..."}}
GOOGLE_TOKEN_MRDARK Third account token {"token":"yA29.a0QQ..."}}

Step 6: Deploy & Test

  1. Push to GitHub: All changes will be automatically deployed
  2. Check Actions: Go to Actions tab to see workflow runs
  3. Test Notifications: Send yourself test emails

πŸ“ Project Structure

gmail-telegram-notifier/
β”œβ”€β”€ πŸ“„ main.py                    # Multi-account notification script
β”œβ”€β”€ πŸ“„ requirements.txt           # Python dependencies
β”œβ”€β”€ πŸ“„ README.md                  # This comprehensive documentation
β”œβ”€β”€ πŸ“„ .gitignore                 # Security protection (credentials ignored)
β”œβ”€β”€ πŸ“ .github/workflows/
β”‚   └── πŸ“„ email-checker.yml      # GitHub Actions workflow
β”œβ”€β”€ 🚫 credentials.json           # OAuth credentials (ignored)
β”œβ”€β”€ 🚫 token*.json                # Authentication tokens (ignored)
β”œβ”€β”€ 🚫 auth_*.py                  # Local authentication scripts (ignored)
└── 🚫 *.log                      # Log files (ignored)

βš™οΈ Configuration

Account Configuration

The system supports up to 3 Gmail accounts defined in main.py:

ACCOUNTS = [
    {
        'name': 'ajit.info999@gmail.com',          # Main account
        'credentials_env': 'GOOGLE_CREDENTIALS',
        'token_env': 'GOOGLE_TOKEN',
    },
    {
        'name': 'ajitbro111@gmail.com',            # Second account
        'credentials_env': 'GOOGLE_CREDENTIALS_AJITBRO',
        'token_env': 'GOOGLE_TOKEN_AJITBRO',
    },
    {
        'name': '421mrdark@gmail.com',             # Third account
        'credentials_env': 'GOOGLE_CREDENTIALS_MRDARK',
        'token_env': 'GOOGLE_TOKEN_MRDARK',
    }
]

Workflow Schedule

# Runs every 5 minutes, 24/7
schedule:
  - cron: '*/5 * * * *'

πŸ” Security Features

Data Protection

  • βœ… No email content storage - Only notifications sent
  • βœ… OAuth2 authentication - Industry standard security
  • βœ… Encrypted GitHub Secrets - Credentials never exposed
  • βœ… Automatic token refresh - No manual intervention needed
  • βœ… Comprehensive .gitignore - Sensitive files never committed

Privacy Compliance

  • πŸ“§ Email reading scope only - No email modification except read status
  • πŸ”’ Local token generation - Authentication happens on your device
  • πŸ›‘οΈ GitHub Actions isolation - Secure, containerized execution
  • πŸ“± Direct Telegram delivery - No third-party services

πŸ“Š Monitoring & Logs

GitHub Actions Logs

Successful Multi-Account Run:

βœ… Created credentials_main.json
βœ… Created credentials_ajitbro.json  
βœ… Created credentials_mrdark.json
βœ… Successfully authenticated ajit.info999@gmail.com
βœ… Successfully authenticated ajitbro111@gmail.com
βœ… Successfully authenticated 421mrdark@gmail.com
πŸ“§ Fetched 4 emails from 421mrdark@gmail.com
βœ… Notification sent for 421mrdark@gmail.com: 199db31f90ac1
βœ… Marked 199db31f90ac1 as read for 421mrdark@gmail.com
--- Completed check. Sent 4 notifications ---

Performance Metrics

Metric Value
Execution Time ~3 seconds
Memory Usage ~15MB
Success Rate 100%
Uptime 24/7
Cost $0.00

🚨 Troubleshooting

Common Issues & Solutions

❌ Authentication Failed

Solution: Re-run authentication script for affected account
Command: python auth_[account].py

❌ No Notifications Received

Check: 
1. Telegram bot token and chat ID
2. GitHub Secrets configuration  
3. GitHub Actions logs for errors

❌ Token Expired Error

Solution: Automatic refresh should handle this
Manual fix: Re-authenticate affected account

❌ Gmail API Quota Exceeded

This is extremely rare with current usage patterns
The system uses minimal API calls

🀝 Contributing

Development Setup

  1. Fork the repository
  2. Create feature branch: git checkout -b feature/amazing-feature
  3. Install dependencies: pip install -r requirements.txt
  4. Run local tests: python test_local_multi.py
  5. Commit changes: git commit -m 'Add amazing feature'
  6. Push branch: git push origin feature/amazing-feature
  7. Open Pull Request

Code Style

  • Follow PEP 8 guidelines
  • Add type hints where possible
  • Include comprehensive logging
  • Maintain security best practices

πŸ™ Acknowledgments

  • Google Gmail API - Robust email access
  • Telegram Bot API - Reliable messaging platform
  • GitHub Actions - Free, powerful CI/CD
  • Python Community - Excellent libraries and support

πŸ“ž Support

Quick Help

FAQ

Q: Can I add more than 3 Gmail accounts? A: Yes! Simply extend the ACCOUNTS array in main.py and add corresponding GitHub Secrets.

Q: How much does this cost to run?
A: Completely free! GitHub Actions provides generous free tier limits.

Q: Is my email data secure? A: Absolutely! No email content is stored. Only notifications are sent to Telegram.

Q: Can I change the notification frequency? A: Yes! Modify the cron schedule in .github/workflows/email-checker.yml


🎯 Ready to Get Started?

  1. ⭐ Star this repository
  2. 🍴 Fork it to your account
  3. πŸš€ Follow the setup instructions above
  4. πŸ“± Enjoy real-time email notifications!

Your multi-account Gmail monitoring system will be live in under 10 minutes! πŸŽ‰

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages