Here’s the updated README with proper formatting for better readability:
A FastAPI-based service for warming up email accounts by gradually increasing sending limits and managing email quotas. Supports Gmail and Outlook integration through OAuth2.
- Gradual email account warmup with quota management
- OAuth2 integration for Gmail and Outlook
- Asynchronous email processing using Redis queues
- Email validation and MX record checking
- Rate limiting and retry mechanisms with exponential backoff
- Real-time status tracking
-
API Layer (
src/api/routes.py)- Provides REST endpoints for email sending and account management
- Handles OAuth callbacks and request validation
- Implements user authentication
-
Queue System (
src/queue/redis_queue.py)- Asynchronous message queue using Redis
- Supports event publishing, subscription, and message persistence
-
Email Processing (
src/services/email_service.py)- Implements email sending logic for Gmail and Outlook
- Manages quotas, errors, and retries
-
Workers (
src/workers/email_worker.py)- Processes background tasks
- Enforces rate limits and retries
- Tracks and logs status updates
The application uses MySQL with the following tables:
-
credentials
- Stores OAuth tokens, user and tenant mappings, and provider details
-
email_quotas
- Tracks daily quotas, warmup progress, and usage statistics
-
email_logs
- Tracks events, statuses, and errors
- Initial Quota: 5 emails/day
- Maximum Quota: 50 emails/day
- Quota Increase Rate:
- After 7 days: +10/day
- After 14 days: +20/day
- After 30 days: +50/day
POST /api/auth/validate- Validate user credentialsPOST /api/auth/gmail- Authenticate Gmail accountGET /api/oauth/callback/{provider}- OAuth callback handlerPOST /api/auth/link-account- Link email provider account
POST /api/send-email- Queue an email for sending
The service includes a web interface (src/static/index.html) that offers:
-
Account Management
- Link Gmail/Outlook accounts via OAuth
- Display account status
-
Email Sending
- Select email provider
- Input recipient, subject, and body
- View send status feedback
The email worker (src/workers/email_worker.py) handles:
-
Queue Processing
- Processes events asynchronously
- Enforces rate limits and quotas
-
Retry Logic
- Maximum of 3 retry attempts
- Implements exponential backoff
- Tracks and logs errors
- Start MySQL and Redis servers
- Set up OAuth credentials in Google/Microsoft developer consoles
- Configure environment variables
- Run the application with hot reload:
uvicorn main:app --host 127.0.0.1 --port 5000 --reload
- Python 3.8+
- MySQL 5.7+
- Redis 6+
- Gmail/Outlook Developer Account
-
Clone the repository:
git clone https://github.com/yourusername/email_wrapup.git cd email_wrapup -
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables (.env):
# Database DB_HOST=localhost DB_PORT=3306 DB_NAME=email_warmup DB_USER=root DB_PASSWORD=your_password # Redis REDIS_HOST=localhost REDIS_PORT=6379 REDIS_QUEUE_NAME=email_queue # OAuth Credentials GMAIL_CLIENT_ID=your_gmail_client_id GMAIL_CLIENT_SECRET=your_gmail_client_secret OUTLOOK_CLIENT_ID=your_outlook_client_id OUTLOOK_CLIENT_SECRET=your_outlook_client_secret # API API_HOST=0.0.0.0 API_PORT=5000 DEBUG=True
-
Initialize the database:
create db named 'email_warmup' and start the server , tables are expected to be created -
Run the application:
uvicorn main:app --host 127.0.0.1 --port 5000 --reload
The service implements comprehensive error handling for:
-
Email Validation
- Verifies format, MX records, and filters throwaway domains
-
Queue Management
- Recovers from connection errors
- Ensures message persistence
- Logs failed events
-
OAuth Flow
- Refreshes tokens and manages errors
This project is licensed under the MIT License.
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This formatting makes the document clear, professional, and easy to read. Let me know if you need further modifications!