Skip to content

v2025.08.2 - Mathematical Gmail Storage Management

Choose a tag to compare

@smcneece smcneece released this 22 Aug 19:58
· 3 commits to main since this release

Release Date: August 22, 2025
Type: Initial release


🧠 Core Intelligence

Mathematical Precision Cleanup

  • Calculates exact number of emails to delete based on storage targets
  • 99.7% accuracy tested (predicted 742MB freed, actual 740MB freed)
  • Smart email counting across all Gmail folders (inbox, sent, trash, spam)
  • Average email size calculation for precise targeting
  • One intelligent run vs 340+ guessing attempts (85+ hours saved)

Advanced Storage Monitoring

  • Drive API integration for accurate total storage across Gmail + Drive + Photos
  • Real-time storage percentage tracking
  • Configurable storage thresholds (default: 75% triggers cleanup)
  • Conservative cleanup targeting (deletes to 73% for safety buffer)

🚀 Major Features

Intelligent Automation

  • Hourly monitoring with smart cleanup calculations
  • Only runs when storage exceeds threshold - no unnecessary processing
  • Batch processing with Gmail API rate limiting (100 emails per batch)
  • Automatic target folder selection (sent items, trash, inbox, custom labels)
  • Evidence preservation mode for security/forensic use cases

Professional Reporting

  • Daily email reports with detailed storage statistics
  • Cleanup activity summaries with exact numbers deleted
  • Email folder breakdowns (inbox, sent, trash counts)
  • Error notifications with detailed logs
  • Complete audit trail of all deletion activity

Smart Configuration

  • Zero-configuration operation after initial setup
  • Configurable email addresses for reports
  • Multiple target folder options (in:sent, in:trash, label:custom)
  • Comprehensive safety features and error handling
  • Professional setup documentation with visual guides

🎯 Perfect For

Security Camera Systems

  • Blue Iris motion alerts and recording notifications
  • Frigate detection alerts
  • NVR system status emails
  • Evidence retention with minimal cleanup

Home Assistant Integration

  • Automated notification cleanup
  • System status email management
  • Sensor alert email handling
  • Android backup account maintenance

Business Applications

  • High-volume Gmail accounts
  • Automated system status emails
  • Data retention compliance
  • Storage cost optimization

📋 Technical Specifications

Requirements

  • Google account with Gmail (free tier supported)
  • Google Apps Script access (free)
  • Drive API and Gmail API enabled

Supported Integrations

  • home-assistant blue-iris frigate nvr security-cameras
  • android backup automation google-apps-script

Performance

  • Processing speed: ~280 emails deleted per minute
  • API efficiency: Respects Gmail quotas and rate limits
  • Storage accuracy: Mathematical precision vs guesswork
  • Error handling: Comprehensive with email notifications

🛠️ Installation

  1. Copy script to Google Apps Script
  2. Enable Drive API and Gmail API services
  3. Configure email addresses in script
  4. Set up hourly cleanup trigger
  5. Set up daily report trigger
  6. Done - fully automated operation

Complete setup guide with screenshots included in documentation.