A self-hosted email campaign management system with business hours scheduling, configurable delays, and Google Sheets integration. Built with FastAPI Python backend and React TypeScript frontend in a unified monorepo.
- Python 3.8+
- Node.js 16+
- Google Sheets API credentials (optional)
-
Clone the repository
git clone <repository-url> cd oss-email-campaigns
-
Backend Setup
cd backend python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -r requirements.txt cp .env.example .env # Edit .env with your SMTP and configuration settings
-
Configure Environment Variables Edit
backend/.envwith your settings:# Required for email sending SMTP_USERNAME=your-email@yourdomain.com SMTP_PASSWORD=your-app-password DEFAULT_FROM_EMAIL=your-email@yourdomain.com # Optional: Google Sheets integration GOOGLE_CREDENTIALS_FILE=credentials.json
-
Database Setup
# Initialize database and run migrations python migrate_add_business_hours.py -
Start Backend
# Use the backend control script ./backend.sh start # Or from project root: ./start-backend.sh # Backend runs on http://localhost:8000
-
Frontend Setup (new terminal)
cd frontend npm install npm start # Frontend runs on http://localhost:3000
- Campaign Creation: Full-featured form with validation
- Google Sheets Integration: Direct import of email lists
- Template Variables: Dynamic personalization ({{name}}, {{company}}, etc.)
- Campaign Status Tracking: Draft, Sending, Completed, Failed states
- Smart Send Times: Configure business hours for professional delivery
- Timezone Support: Respect recipient timezones for optimal delivery
- Weekend Handling: Option to skip weekends for B2B campaigns
- Queue Management: Campaigns automatically queue outside business hours
- Configurable Delays: Random delays between 1-60 minutes
- Per-Campaign Settings: Enable/disable delays individually
- Smart Logic: Delays between ALL emails (success and failure)
- Rate Limiting: Built-in protection against spam detection
- Modern Design: Clean, intuitive interface
- Responsive Layout: Works on desktop and mobile
- Real-time Updates: Live campaign progress tracking
- Form Validation: Comprehensive error handling and feedback
oss-email-campaigns/
βββ backend/ # FastAPI backend
β βββ app/
β β βββ main.py # Main application with campaign logic
β β βββ models.py # Database models with business hours
β β βββ schemas.py # API schemas with scheduling
β β βββ services/ # Email and Google Sheets services
β β βββ utils/ # Business hours and scheduling utilities
β βββ migrate_add_business_hours.py
β βββ requirements.txt
β βββ backend.sh # Backend control script
β βββ .env.example # Environment configuration template
βββ frontend/ # React TypeScript frontend
β βββ src/
β β βββ pages/CreateCampaign.tsx # Campaign creation with scheduling
β β βββ pages/Campaigns.tsx # Campaign management
β β βββ components/ # Reusable UI components
β β βββ types/index.ts # TypeScript definitions
β βββ package.json
βββ start-backend.sh # Quick backend start script
βββ stop-backend.sh # Backend stop script
βββ README.md
Create campaigns with flexible timing:
- Immediate Send: Send emails right away
- Business Hours: Respect business hours (9 AM - 5 PM)
- Custom Delays: Random delays between emails (1-60 minutes)
- Weekend Handling: Skip or include weekend delivery
Key settings in backend/.env:
# Email Configuration (Required)
SMTP_HOST=smtp.spacemail.com
SMTP_PORT=587
SMTP_USERNAME=your-email@domain.com
SMTP_PASSWORD=your-app-password
DEFAULT_FROM_EMAIL=your-email@domain.com
# Google Sheets (Optional)
GOOGLE_CREDENTIALS_FILE=credentials.json
# Application Settings
ENVIRONMENT=development
DEBUG=true
CORS_ORIGINS=http://localhost:3000
# Security
SECRET_KEY=your-super-secret-key-change-this-in-production
# Database
DATABASE_URL=sqlite:///./email_campaigns.db- Campaign Creation: User configures business hours and timezone
- Queue Management: Campaigns outside business hours are queued
- Smart Delivery: Emails sent only during configured business hours
- Weekend Handling: Option to skip weekends for B2B campaigns
- Email Processing: System processes each email in sequence
- Delay Application: After each email (success or failure):
- Skip delay for last email
- Apply random delay between configured min/max
- Continue to next email
Example with business hours (9 AM - 5 PM) and 2-4 minute delays:
Campaign created at 8:30 AM β β³ Queued until 9:00 AM
9:00 AM - Email 1: β
Sent β β³ Wait 3 minutes
9:03 AM - Email 2: β Failed β β³ Wait 2 minutes
9:05 AM - Email 3: β
Sent β β³ Wait 4 minutes
...continues within business hours
cd backend
python -m pytest # Run tests
./test-integration.sh # Integration testscd frontend
npm test # Jest tests
./test-integration.sh # UI integration testsBoth backend and frontend are production-ready:
Backend Options:
- Render: Recommended (includes PostgreSQL)
- Railway: Great for Python apps
- and more...
Frontend Options: Note: currently no authentication is implemented
- Local Only: Run
npm run buildand serve locally With proper authentication you could deploy to any of the following: - Vercel: Build with
npm run buildand deploy - Netlify: Automatic builds from Git
- Render Static Sites: Part of same infrastructure
- and more...
Database:
- Development: SQLite (included)
- Production: PostgreSQL (auto-provisioned on most platforms)
- and more...
Set these in your hosting platform:
ENVIRONMENT=productionDATABASE_URL=postgresql://...(auto-set by most platforms)SMTP_USERNAME,SMTP_PASSWORD(your email credentials)SECRET_KEY(generate a secure key)CORS_ORIGINS=https://your-frontend-url.com
# All-in-one backend control (recommended)
./backend.sh start # Start the server
./backend.sh stop # Stop the server
./backend.sh restart # Restart the server
./backend.sh status # Check if running
# Alternative methods (from project root)
./start-backend.sh # Start backend
./stop-backend.sh # Stop backend# Start development environment
./backend.sh start # Terminal 1: Start backend
cd frontend && npm start # Terminal 2: Start frontend
# Check logs
tail -f backend.log # Monitor backend logs
# Database management
python migrate_add_business_hours.py # Run migrations- Backend: Add API endpoints in
app/main.py - Frontend: Add React components in
src/pages/orsrc/components/ - Database: Create migration scripts for schema changes
- Types: Update TypeScript interfaces in
frontend/src/types/
- Backend logs: Check console output during email sending
- Frontend: React DevTools and browser console
- Database: Use SQLite browser to inspect campaign data
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
MIT License - see LICENSE file for details.
- Backend API: http://localhost:8000/docs (Swagger UI)
- Frontend App: http://localhost:3000
- Google Sheets Setup: backend/GOOGLE_SHEETS_SETUP.md
Leave a star! π