{"id":30570593,"url":"https://github.com/chai-dev682/outlook2gmail","last_synced_at":"2025-08-28T20:18:53.380Z","repository":{"id":309913073,"uuid":"1034499993","full_name":"chai-dev682/outlook2gmail","owner":"chai-dev682","description":null,"archived":false,"fork":false,"pushed_at":"2025-08-14T13:12:43.000Z","size":79,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-14T15:13:12.159Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chai-dev682.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-08T13:42:48.000Z","updated_at":"2025-08-14T13:12:47.000Z","dependencies_parsed_at":"2025-08-14T15:13:19.814Z","dependency_job_id":"4805ed9a-c23d-4e09-bd86-98118a1f5c2c","html_url":"https://github.com/chai-dev682/outlook2gmail","commit_stats":null,"previous_names":["chai-dev682/outlook2gmail"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/chai-dev682/outlook2gmail","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chai-dev682%2Foutlook2gmail","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chai-dev682%2Foutlook2gmail/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chai-dev682%2Foutlook2gmail/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chai-dev682%2Foutlook2gmail/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chai-dev682","download_url":"https://codeload.github.com/chai-dev682/outlook2gmail/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chai-dev682%2Foutlook2gmail/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272549454,"owners_count":24953572,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-28T02:00:10.768Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-08-28T20:18:50.663Z","updated_at":"2025-08-28T20:18:53.366Z","avatar_url":"https://github.com/chai-dev682.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Outlook to Gmail Forwarder\n\nA comprehensive Python solution for forwarding Outlook emails to specific Gmail accounts based on customizable rules. This solution supports up to 1,000 emails at a time with automated forwarding at set intervals and flexible rule-based routing.\n\n## Features\n\n### Core Functionality\n- ✅ **Multi-Account Support**: Forward from multiple Outlook 365 accounts to multiple Gmail accounts\n- ✅ **Rule-Based Forwarding**: Create sophisticated rules to route emails to specific Gmail accounts\n- ✅ **Automated Scheduling**: Set interval-based forwarding with manual trigger options\n- ✅ **Bulk Processing**: Handle up to 1,000 emails per run with efficient batch processing\n- ✅ **Account Monitoring**: Track which accounts are not forwarding with detailed error reporting\n- ✅ **Easy Integration**: Import/export accounts via CSV with bulk management\n- ✅ **Portable**: Move between servers easily with Docker support\n- ✅ **Web UI**: Modern Flask-based interface for easy management\n- ✅ **CLI Tools**: Command-line interface for automation and scripting\n\n### Advanced Features\n- 📧 **Smart Routing**: Route emails based on subject, sender, domain, attachments, and more\n- 🔄 **Token Management**: Automatic OAuth token refresh for both Outlook and Gmail\n- 📊 **Analytics**: Detailed forwarding history and statistics\n- 🛡️ **Security**: Encrypted token storage with configurable encryption keys\n- 🔍 **Testing**: Built-in rule testing and account connectivity verification\n- 📱 **Responsive UI**: Mobile-friendly web interface\n- 🐳 **Docker Support**: Containerized deployment for easy portability\n\n## Quick Start\n\n### Prerequisites\n- Python 3.8+\n- Microsoft Azure App Registration (for Outlook API)\n- Google Cloud Project with Gmail API enabled\n\n### Installation\n\n1. **Clone the repository**\n```bash\ngit clone \u003crepository-url\u003e\ncd outlook2gmail\n```\n\n2. **Install dependencies**\n```bash\npip install -r requirements.txt\n```\n\n3. **Set up environment variables**\n```bash\ncp .env.example .env\n# Edit .env with your configuration\n```\n\n4. **Initialize the database**\n```bash\npython cli.py init-db\n```\n\n5. **Start the application**\n```bash\npython app.py\n```\n\n## Configuration\n\n### Environment Variables\n\nCreate a `.env` file with the following configuration:\n\n```env\n# Flask Configuration\nFLASK_ENV=development\nSECRET_KEY=your-secret-key-here\nAPP_URL=http://localhost:5000\n\n# Database\nDATABASE_URL=sqlite:///outlook2gmail.db\n\n# Microsoft OAuth (Outlook)\nMICROSOFT_CLIENT_ID=your-outlook-client-id\nMICROSOFT_CLIENT_SECRET=your-outlook-client-secret\nMICROSOFT_TENANT_ID=common\n\n# Gmail OAuth (for multiple accounts)\nGMAIL_CLIENT_ID=your-gmail-client-id\nGMAIL_CLIENT_SECRET=your-gmail-client-secret\n\n# Legacy Gmail API (for single account)\nGMAIL_CREDENTIALS_FILE=config/gmail_credentials.json\nGMAIL_TARGET_EMAIL=legacy-target@gmail.com\n\n# Forwarding Settings\nBATCH_SIZE=100\nMAX_EMAILS_PER_RUN=1000\nFORWARD_INTERVAL_MINUTES=30\nUSE_ENHANCED_FORWARDER=true\n\n# Optional Redis Configuration\nREDIS_URL=redis://localhost:6379/0\n```\n\n### OAuth Setup\n\n#### Microsoft (Outlook) Setup\n1. Go to [Azure Portal](https://portal.azure.com)\n2. Register a new application\n3. Add redirect URI: `http://localhost:5000/auth/callback`\n4. Grant permissions: `Mail.Read`, `Mail.Send`, `offline_access`\n5. Copy Client ID and Secret to `.env`\n\n#### Gmail Setup\n1. Go to [Google Cloud Console](https://console.cloud.google.com)\n2. Enable Gmail API\n3. Create OAuth 2.0 credentials\n4. Add redirect URI: `http://localhost:5000/gmail/callback`\n5. Download credentials JSON and save as `config/gmail_credentials.json`\n6. Copy Client ID and Secret to `.env`\n\n## Usage\n\n### Web Interface\n\n1. **Access the dashboard**: http://localhost:5000\n2. **Add Outlook accounts**: Navigate to Accounts → Add Account\n3. **Add Gmail accounts**: Navigate to Gmail Accounts → Add Gmail Account\n4. **Create forwarding rules**: Navigate to Forwarding Rules → Create Rule\n5. **Monitor forwarding**: Check dashboard for statistics and job status\n\n### Command Line Interface\n\n#### Account Management\n```bash\n# List Outlook accounts\npython cli.py list-accounts\n\n# List Gmail accounts\npython cli.py gmail list\n\n# Test account connections\npython cli.py test-account 1\npython cli.py gmail test 1\n\n# Import accounts from CSV\npython cli.py import-accounts --csv-file accounts.csv\n```\n\n#### Forwarding Rules\n```bash\n# List all rules\npython cli.py rules list\n\n# Create a new rule\npython cli.py rules create \\\n  --rule-name \"Important Emails\" \\\n  --outlook-account-id 1 \\\n  --gmail-account-id 1 \\\n  --criteria-file rule_criteria.json\n\n# Test a rule\npython cli.py rules test 1\n\n# Create sample rule criteria\npython cli.py create-sample-rule\n```\n\n#### Manual Forwarding\n```bash\n# Forward with rules (recommended)\npython cli.py forward-now --use-rules --max-emails 100\n\n# Legacy forwarding (single Gmail target)\npython cli.py forward-now --max-emails 100\n\n# Forward specific account\npython cli.py forward-now --account-id 1 --use-rules\n```\n\n## Forwarding Rules\n\nCreate sophisticated rules to route emails to specific Gmail accounts based on various criteria.\n\n### Rule Criteria Examples\n\n**Simple rule** - Forward all emails from a specific domain:\n```json\n{\n  \"field\": \"sender_domain\",\n  \"operator\": \"equals\",\n  \"value\": \"company.com\"\n}\n```\n\n**Complex rule** - Forward important emails from specific senders:\n```json\n{\n  \"and\": [\n    {\n      \"field\": \"importance\",\n      \"operator\": \"equals\",\n      \"value\": \"high\"\n    },\n    {\n      \"field\": \"sender_domain\",\n      \"operator\": \"in_list\",\n      \"value\": [\"company.com\", \"partner.com\"]\n    }\n  ]\n}\n```\n\n**Advanced rule** - Forward emails with attachments containing specific keywords:\n```json\n{\n  \"and\": [\n    {\n      \"field\": \"has_attachments\",\n      \"operator\": \"equals\",\n      \"value\": true\n    },\n    {\n      \"or\": [\n        {\n          \"field\": \"subject\",\n          \"operator\": \"contains\",\n          \"value\": \"invoice\"\n        },\n        {\n          \"field\": \"subject\",\n          \"operator\": \"contains\",\n          \"value\": \"receipt\"\n        }\n      ]\n    }\n  ]\n}\n```\n\n### Available Fields\n- `subject` - Email subject line\n- `sender` - Sender email address\n- `sender_name` - Sender display name\n- `sender_domain` - Sender's email domain\n- `body` - Email body content\n- `has_attachments` - Boolean for attachment presence\n- `importance` - Email importance (low, normal, high)\n- `received_date` - When email was received\n- `to_recipients` - To recipients list\n- `cc_recipients` - CC recipients list\n\n### Available Operators\n- `equals` - Exact match (case insensitive)\n- `contains` - Contains substring (case insensitive)\n- `starts_with` - Starts with string (case insensitive)\n- `ends_with` - Ends with string (case insensitive)\n- `regex` - Regular expression match\n- `in_list` - Value in comma-separated list\n- `greater_than` - Numeric comparison\n- `less_than` - Numeric comparison\n- `date_after` - Date comparison\n- `date_before` - Date comparison\n\n## CSV Import/Export\n\n### Account Import Format\n```csv\nusername,password,full_name,recovery_email,birthday,proxy_host,proxy_port,proxy_username,proxy_password\nuser1@outlook.com,password123,John Doe,recovery@email.com,1990-01-01,proxy.server.com,8080,proxyuser,proxypass\nuser2@outlook.com,password456,Jane Smith,jane.recovery@email.com,1985-05-15,,,\n```\n\n### Export Accounts\n```bash\n# Export without sensitive data\npython cli.py export-accounts --output accounts_export.csv\n\n# Export with tokens (be careful with security)\npython cli.py export-accounts --output accounts_full.csv --include-tokens\n```\n\n## Docker Deployment\n\n### Using Docker Compose\n\n1. **Create docker-compose.yml**:\n```yaml\nversion: '3.8'\nservices:\n  outlook2gmail:\n    build: .\n    ports:\n      - \"5000:5000\"\n    environment:\n      - FLASK_ENV=production\n      - DATABASE_URL=sqlite:///data/outlook2gmail.db\n    volumes:\n      - ./data:/app/data\n      - ./config:/app/config\n      - ./logs:/app/logs\n    restart: unless-stopped\n\n  redis:\n    image: redis:alpine\n    ports:\n      - \"6379:6379\"\n    restart: unless-stopped\n```\n\n2. **Deploy**:\n```bash\ndocker-compose up -d\n```\n\n### Standalone Docker\n```bash\n# Build image\ndocker build -t outlook2gmail .\n\n# Run container\ndocker run -d \\\n  -p 5000:5000 \\\n  -v $(pwd)/data:/app/data \\\n  -v $(pwd)/config:/app/config \\\n  -v $(pwd)/logs:/app/logs \\\n  --env-file .env \\\n  outlook2gmail\n```\n\n## Monitoring and Troubleshooting\n\n### Account Status\n- Check the dashboard for account status indicators\n- Red badges indicate accounts with errors\n- Use the \"Test\" button to verify connectivity\n\n### Common Issues\n\n**Token Expired**\n- Symptoms: 401 errors in logs\n- Solution: Re-authenticate accounts through web UI\n\n**Rate Limiting**\n- Symptoms: 429 errors in logs\n- Solution: Reduce batch size or increase interval\n\n**No Matching Rules**\n- Symptoms: Emails not being forwarded\n- Solution: Check rule criteria and create default rules\n\n### Logs\n```bash\n# View application logs\ntail -f logs/app.log\n\n# View forwarding job logs\npython cli.py jobs\n```\n\n## API Reference\n\n### REST Endpoints\n\n#### Outlook Accounts\n- `GET /accounts` - List accounts\n- `GET /accounts/{id}` - Account details\n- `POST /api/accounts/{id}/toggle` - Toggle account status\n- `POST /api/accounts/{id}/test` - Test account connection\n\n#### Gmail Accounts\n- `GET /gmail-accounts` - List Gmail accounts\n- `GET /gmail-accounts/{id}` - Gmail account details\n- `POST /api/gmail-accounts/{id}/toggle` - Toggle Gmail account status\n- `POST /api/gmail-accounts/{id}/test` - Test Gmail account connection\n\n#### Forwarding Rules\n- `GET /forwarding-rules` - List rules\n- `POST /forwarding-rules/create` - Create rule\n- `PUT /forwarding-rules/{id}/edit` - Update rule\n- `DELETE /api/forwarding-rules/{id}/delete` - Delete rule\n- `POST /api/forwarding-rules/{id}/test` - Test rule\n\n#### Jobs\n- `GET /jobs` - List forwarding jobs\n- `POST /api/forward/trigger` - Trigger manual forwarding\n\n## Development\n\n### Setting up Development Environment\n\n1. **Create virtual environment**:\n```bash\npython -m venv venv\nsource venv/bin/activate  # On Windows: venv\\Scripts\\activate\n```\n\n2. **Install development dependencies**:\n```bash\npip install -r requirements.txt\npip install pytest pytest-cov black flake8\n```\n\n3. **Run tests**:\n```bash\npython -m pytest tests/\n```\n\n4. **Code formatting**:\n```bash\nblack src/ cli.py app.py\nflake8 src/ cli.py app.py\n```\n\n### Project Structure\n```\noutlook2gmail/\n├── app.py                 # Flask web application\n├── cli.py                 # Command-line interface\n├── requirements.txt       # Python dependencies\n├── Dockerfile            # Docker configuration\n├── config/               # Configuration files\n│   ├── config.py         # Application configuration\n│   └── gmail_credentials.json\n├── src/                  # Source code\n│   ├── models.py         # Database models\n│   ├── microsoft_auth.py # Outlook OAuth handling\n│   ├── gmail_service.py  # Gmail API service\n│   ├── email_forwarder.py # Legacy email forwarder\n│   ├── enhanced_email_forwarder.py # Rule-based forwarder\n│   ├── forwarding_rule_engine.py  # Rule evaluation engine\n│   ├── csv_importer.py   # CSV import/export\n│   └── scheduler.py      # Job scheduling\n├── templates/            # HTML templates\n├── static/              # Static assets\n├── tests/               # Test files\n├── logs/                # Application logs\n└── uploads/             # File uploads\n```\n\n## Security Considerations\n\n### Token Security\n- All OAuth tokens are encrypted before storage\n- Encryption keys are automatically generated and stored securely\n- Never expose refresh tokens in logs or exports\n\n### Network Security\n- Use HTTPS in production\n- Configure proper firewall rules\n- Consider VPN for server access\n\n### Access Control\n- Change default admin credentials\n- Use strong passwords\n- Implement additional authentication if needed\n\n## Performance Optimization\n\n### Large Scale Deployments\n- Use PostgreSQL or MySQL instead of SQLite for better performance\n- Configure Redis for session storage and caching\n- Use Celery for background job processing\n- Set up load balancing for multiple instances\n\n### Batch Processing\n- Adjust `BATCH_SIZE` based on your server capacity\n- Monitor memory usage during large email processing\n- Use `MAX_EMAILS_PER_RUN` to limit job duration\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Make your changes\n4. Add tests for new functionality\n5. Ensure all tests pass\n6. Submit a pull request\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n\n## Support\n\nFor issues, questions, or contributions:\n- Create an issue on GitHub\n- Check the troubleshooting section\n- Review the logs for detailed error information\n\n---\n\n**Note**: This application handles sensitive email data. Always ensure proper security measures are in place when deploying to production environments. ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchai-dev682%2Foutlook2gmail","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchai-dev682%2Foutlook2gmail","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchai-dev682%2Foutlook2gmail/lists"}