Skip to content

An automated email system sending AI-generated messages with images/videos to Walton Cantonment Board, Punjab CM, and stakeholders, persistently advocating for neglected roads (Bedian Rd, Bhatta Chowk, Ali View Society) vs. recently repaired areas near Nadirabad/PAF Golf Course, ensuring equitable road maintenance.

Notifications You must be signed in to change notification settings

sultan18kh/advocacy_email_system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

38 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Automated Government Email Scheduler

This solution sends automated emails to government officials about road conditions in Bedian Road & Ali View Garden area, Lahore.

πŸ“‹ Requirements

requirements.txt

schedule==1.2.0
pytz==2023.3

Note: Previous versions incorrectly listed secure-smtplib which doesn't exist. The system uses Python's built-in smtplib.

πŸ—οΈ Setup Instructions

Step 1: Create Email Account

You only need ONE email account to get started!

Choose one of these options:

  1. Gmail Account (Recommended)

    • Go to gmail.com and create new account
    • Enable 2-Factor Authentication
    • Generate App Password: Gmail β†’ Settings β†’ Security β†’ App Passwords
    • Note down email and app password
  2. Outlook Account

    • Go to outlook.com and create new account
    • Enable 2-Factor Authentication if required
    • Note down email and password
  3. Yahoo Account

    • Go to yahoo.com and create new account
    • Generate App Password if 2FA enabled
    • Note down email and password

Optional: Create 2-3 accounts for better rotation and anti-blocking protection.

Step 2: GitHub Repository Setup

  1. Create New Repository

    # Create new repo on GitHub
    # Name: government-road-complaints
    # Description: Automated system for road infrastructure complaints
    # Set to Private for security
  2. Add Files to Repository

    government-road-complaints/
    β”œβ”€β”€ .github/
    β”‚   └── workflows/
    β”‚       └── send-daily-emails.yml
    β”œβ”€β”€ src/
    β”‚   β”œβ”€β”€ send_single_email.py
    β”‚   β”œβ”€β”€ test_email.py
    β”‚   β”œβ”€β”€ setup.py
    β”‚   └── config.py
    β”œβ”€β”€ docs/
    β”‚   β”œβ”€β”€ QUICK_START.md
    β”‚   β”œβ”€β”€ GITHUB_SECRETS_GUIDE.md
    β”‚   β”œβ”€β”€ SETUP_SECRETS.md
    β”‚   └── DEPLOYMENT_CHECKLIST.md
    β”œβ”€β”€ requirements.txt
    β”œβ”€β”€ README.md
    └── media/
        β”œβ”€β”€ road_photo1.jpg
        β”œβ”€β”€ road_photo2.jpg
        β”œβ”€β”€ pothole_video.mp4
        └── flooding_video.mp4
    
  3. Add Your Media Files

    • Take photos/videos of road conditions
    • Upload to media/ folder in repository
    • Supported formats: JPG, PNG, MP4, MOV, PDF, DOC, ZIP, and more
    • Keep file sizes under 25MB each
    • NEW: System automatically discovers all valid files

Step 3: Configure GitHub Secrets

Go to your repository β†’ Settings β†’ Secrets and Variables β†’ Actions β†’ New Repository Secret

Minimum Setup (1 Email Service):

GMAIL_EMAIL = your_gmail@gmail.com
GMAIL_APP_PASSWORD = your_gmail_app_password

OR

OUTLOOK_EMAIL = your_outlook@outlook.com
OUTLOOK_PASSWORD = your_outlook_password

OR

YAHOO_EMAIL = your_yahoo@yahoo.com
YAHOO_PASSWORD = your_yahoo_password

Optional (For Better Rotation): Add all 6 secrets if you want to use multiple email services.

Step 4: Test Setup

  1. Install Dependencies Locally (Optional)

    pip install -r requirements.txt
  2. Run Local Tests

    python src/test_email.py
  3. Manual GitHub Test

    • Go to Actions tab in your repository
    • Click "Government Road Complaint Emails (Mon/Wed/Fri)"
    • Click "Run workflow" β†’ "Run workflow"
    • Check if emails are sent successfully

Step 5: Schedule Activation

The automated schedule will run Monday, Wednesday, and Friday at 9:00 AM Pakistan Time automatically once the workflow file is in place.

πŸ›‘οΈ Anti-Spam & Anti-Blocking Features

Email Rotation

  • Uses up to 3 different email services (Gmail, Outlook, Yahoo)
  • Rotates between services to avoid single-service blocking
  • Different templates and content each day

Content Variation

  • 3 different email templates (English formal, Urdu, Legal)
  • Templates rotate based on day of year
  • Unique timestamps and reference numbers
  • Natural language variations

Sending Patterns

  • Random delays between 10-60 seconds
  • Professional, legitimate complaint format
  • Proper email headers and formatting
  • Reduced frequency: Mon/Wed/Fri only (not daily)

Spam Prevention

  • Professional subject lines
  • Legitimate government complaint content
  • Proper email authentication
  • Timezone-aware timestamps

πŸ“¨ Email Templates Features

Template 1: Urgent English

  • Emergency tone with constitutional references
  • Detailed impact documentation
  • Comparison with better-maintained areas
  • Professional formatting

Template 2: Formal Urdu

  • Respectful Urdu language
  • Cultural context appropriate
  • Government protocol compliant
  • Local context emphasis

Template 3: Citizen Rights

  • Legal framework references
  • Constitutional rights basis
  • Escalation timeline mentioned
  • Documentation emphasis

πŸ—‚οΈ File Structure

β”œβ”€β”€ src/                        # Python source code
β”‚   β”œβ”€β”€ send_single_email.py    # Main email sender (UPDATED)
β”‚   β”œβ”€β”€ test_email.py          # Test suite (ENHANCED)
β”‚   β”œβ”€β”€ setup.py               # Setup script
β”‚   └── config.py              # Configuration (UPDATED)
β”œβ”€β”€ docs/                       # Documentation
β”‚   β”œβ”€β”€ QUICK_START.md         # Quick setup guide
β”‚   β”œβ”€β”€ GITHUB_SECRETS_GUIDE.md # Secrets configuration
β”‚   β”œβ”€β”€ SETUP_SECRETS.md       # Complete setup guide
β”‚   └── DEPLOYMENT_CHECKLIST.md # Deployment checklist
β”œβ”€β”€ .github/workflows/
β”‚   └── send-daily-emails.yml   # GitHub Actions workflow (Mon/Wed/Fri)
β”œβ”€β”€ requirements.txt            # Python dependencies (FIXED)
β”œβ”€β”€ README.md                   # This guide
└── media/                      # Your photos/videos (AUTO-DISCOVERED)
    β”œβ”€β”€ [any_photo_name].jpg
    β”œβ”€β”€ [any_video_name].mp4
    └── [any_document_name].pdf

πŸ†• New Features (Latest Version)

βœ… Automatic Media File Discovery

  • No more fixed filenames - use any descriptive names
  • 22 supported file types - images, videos, documents, archives
  • Smart size management - automatic validation and limits
  • Detailed logging - shows what's included/skipped

βœ… Enhanced Timezone Support

  • Pakistan Standard Time (PKT) support with pytz
  • Accurate scheduling - proper UTC to PKT conversion
  • Timezone-aware timestamps in all emails

βœ… Improved Error Handling

  • Specific SMTP errors - authentication, connection, sending
  • File validation - type, size, accessibility checks
  • Better debugging - detailed error messages and solutions

βœ… Reduced Frequency

  • Mon/Wed/Fri only - more sustainable approach
  • Professional pattern - avoids daily spam appearance
  • Better compliance - less likely to trigger filters

🎯 Targeting Strategy

Primary Recipients

  • Walton Cantonment Board
  • Punjab CM Office
  • Local Development Authority
  • District Administration Lahore
  • Punjab Highway Department

Schedule

  • Monday: Administrative focus
  • Wednesday: Follow-up and escalation
  • Friday: Weekly summary and pressure

πŸ“Š Monitoring & Analytics

GitHub Actions Logs

  • Check execution status Mon/Wed/Fri
  • Monitor email sending success
  • Track template rotation
  • View detailed error messages

Email Tracking

  • Monitor government responses
  • Track media coverage
  • Document any action taken
  • Maintain complaint log

πŸ”§ Troubleshooting

Common Issues

  1. "No module named 'pytz'" Error

    pip install pytz
    # or
    pip install -r requirements.txt
  2. Emails Not Sending

    • Check GitHub Secrets are set correctly
    • Verify email passwords/app passwords
    • Check spam folders for test emails
  3. Workflow Not Running

    • Look for "Government Road Complaint Emails (Mon/Wed/Fri)" (exact name)
    • Check cron syntax: 0 4 * * 1,3,5 (Mon/Wed/Fri at 4 AM UTC)
    • Verify repository is not archived
  4. Media Files Not Found

    • Ensure files are in media/ directory
    • Check file types are supported (see list above)
    • Verify files are under 25MB each

Support Commands

# Install dependencies
pip install -r requirements.txt

# Test configuration
python src/test_email.py

# Check GitHub Actions status
# Go to repository β†’ Actions β†’ Latest run

πŸ“ˆ Scaling Options

Increase Frequency

  • Modify cron schedule: 0 4 * * * for daily
  • Add multiple sends per day
  • Target different officials at different times

Add More Email Services

  • ProtonMail accounts
  • Custom SMTP servers
  • Business email accounts

Enhanced Media

  • Regular photo/video updates
  • Drone footage of area
  • Time-lapse documentation
  • Comparative area photos

βš–οΈ Legal Compliance

Legitimate Use

  • Constitutional right to petition government
  • Freedom of expression protection
  • Citizen complaint mechanisms
  • Public service accountability

Professional Standards

  • Respectful communication tone
  • Factual information only
  • No threatening language
  • Clear identification as automated system

πŸ’° Cost Analysis

Free Tier Usage

  • GitHub Actions: 2000 minutes/month (free)
  • Email accounts: Free versions sufficient
  • File storage: GitHub repository free
  • Total Monthly Cost: $0

Optional Upgrades

  • GitHub Pro: $4/month (more Actions minutes)
  • Premium email accounts: $5-10/month
  • Custom domain: $10-15/year

🎯 Success Metrics

Short Term (1-3 months)

  • Email delivery success rate > 95%
  • Zero email account blocks
  • Template rotation working
  • Government acknowledgment received

Medium Term (3-6 months)

  • Media coverage of issue
  • Government inspection visit
  • Preliminary repair work started
  • Community support mobilized

Long Term (6-12 months)

  • Complete road reconstruction
  • Drainage system installation
  • Street lighting restored
  • Regular maintenance schedule

πŸš€ Quick Start Checklist

  • Install dependencies: pip install -r requirements.txt
  • Create at least one email account (Gmail, Outlook, or Yahoo)
  • Set up GitHub repository
  • Add all code files
  • Upload media files (any supported format, any filename)
  • Configure GitHub Secrets (minimum 1 email service)
  • Test: python src/test_email.py
  • Test manual workflow execution
  • Verify Mon/Wed/Fri automation is working
  • Monitor for government responses

Your automated government accountability system is now ready! πŸ†


Latest Update: Enhanced with automatic file discovery, timezone support, improved error handling, and reduced to Mon/Wed/Fri schedule for better sustainability.

About

An automated email system sending AI-generated messages with images/videos to Walton Cantonment Board, Punjab CM, and stakeholders, persistently advocating for neglected roads (Bedian Rd, Bhatta Chowk, Ali View Society) vs. recently repaired areas near Nadirabad/PAF Golf Course, ensuring equitable road maintenance.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published