<- Back to Projects

HyTrackV3

Email-driven shipment tracker for Blue Dart and Delhivery. Reads waybills from your inbox, watches each one, and emails a styled update with a journey log whenever the status changes.

PythonSeleniumSQLiteBeautifulSoupIMAP

HyTrackV3

Status GitHub Release Python Selenium License

HyTrackV3 is an automated shipment tracker. It watches a mailbox over IMAP, picks out Blue Dart and Delhivery waybill numbers, checks each one with Requests, BeautifulSoup and headless Chrome, and emails you a styled update whenever a shipment’s status changes.

Try It Now

You can use the hosted instance to track your packages straight away.

Email your Blue Dart or Delhivery tracking numbers (waybills) to:

notify@hyclotron.com

HyTrack picks up the waybills, starts watching each package, and emails you whenever its status changes. Reply to any update with another waybill to track that one too.

The Update Email

Every update leads with the status and the latest scan, then the route, the expected delivery date, and a journey log of recent scans. Statuses fall into four groups, each with its own badge, and every message carries a plain-text version for clients that don’t render HTML. The design matches this site’s ivory theme, with every colour inlined so it survives email clients that strip styles.

HyTrack in transit email for a Blue Dart shipment, showing the status, route and journey log
In transit · Blue Dart · The latest scan is highlighted in orange, with the route and expected delivery above the journey log.
HyTrack out for delivery email for a Delhivery shipment, showing the status, route and journey log
Out for delivery · Delhivery · Long journeys show the eight most recent scans and count the earlier ones left on the courier site.
HyTrack delivered email for a Blue Dart shipment, showing the status, route and journey log
Delivered · Blue Dart · Expected delivery drops away once the parcel arrives, and the current scan turns slate.
HyTrack needs attention email for a Delhivery shipment, showing the status, route and journey log
Needs attention · Delhivery · Failed attempts, refusals, returns and damage get a red badge so they stand out in your inbox.

On a Phone

Below 520 pixels the timestamp moves above each scan, the route and delivery date stack, and the card tightens up, so the journey log stays readable on a phone.

HyTrack in transit email on a phone-width screen
In transit
HyTrack out for delivery email on a phone-width screen
Out for delivery
HyTrack delivered email on a phone-width screen
Delivered
HyTrack needs attention email on a phone-width screen
Needs attention

Features

Inbox-Driven Tracking

Connects to a mailbox over IMAP and reads waybill numbers from the subject and body of new mail, so tracking a parcel is as simple as forwarding the shipping email.

Blue Dart and Delhivery

Blue Dart is fetched with Requests and BeautifulSoup over a retrying session. Delhivery’s dynamic tracking page is read with Selenium in headless Chrome, including the scan history.

Careful Ingestion

Skips numbers that look like phone numbers, ignores bounces, auto-replies and mail that fails SPF, DKIM or DMARC, and caps waybills per email and active shipments per sender.

Status-Aware

Each courier scan is sorted into in transit, out for delivery, delivered or needs attention, so a failed attempt or a return is flagged rather than buried in courier jargon.

Journey Log Emails

Updates show the route, expected delivery and the eight latest scans, in HTML with a plain-text fallback. A send that fails is retried on the next run.

Self-Maintaining

A local SQLite database records every shipment and the last event seen. Delivered parcels stop being checked, and waybills that never resolve or stop changing are retired.

Cron-Friendly

Each run is a single pass that’s safe to schedule: a lock makes an overlapping run exit straight away, and the log file rotates on its own.

Tested in CI

Unit tests cover parsing, classification, ingestion and the email builder, and run on Python 3.12, 3.13 and 3.14 in GitHub Actions alongside CodeQL scanning.

How It Works

  1. Read the inbox. Each run fetches unseen mail over IMAP and pulls out waybill numbers, matching each one to its courier.
  2. Check the courier. Every active shipment’s latest scan and history are fetched from Blue Dart or Delhivery.
  3. Compare. The latest event is hashed and compared with the last one stored in SQLite, so only real changes count.
  4. Notify. On a change, HyTrack sends the update email over SMTP to whoever sent in the waybill.
  5. Tidy up. Delivered shipments stop being checked, and stale ones expire after a configurable number of days.

Prerequisites

Before running HyTrackV3 yourself, make sure you have:

  • Python 3.10+
  • Google Chrome (latest stable version)
  • Git

Installation

  1. Clone the repository:

    git clone https://github.com/nicx17/HyTrackV3.git
    cd HyTrackV3
  2. Set up a virtual environment:

    python -m venv .venv
    source .venv/bin/activate  # On Windows: .venv\Scripts\activate
  3. Install dependencies:

    pip install -r requirements.txt

    This installs selenium, beautifulsoup4, requests, webdriver-manager and the other required packages.

Configuration

HyTrackV3 reads its settings from environment variables.

  1. Copy the sample configuration:

    cp sample.env.txt .env
  2. Edit .env with your mail accounts, then adjust the limits if you like:

    # Email IMAP configuration (for fetching tracking numbers)
    IMAP_SERVER="imap.gmail.com"
    IMAP_PORT=993
    EMAIL_ADDRESS="your_email@example.com"
    EMAIL_PASSWORD="your_app_specific_password"
    
    # Email SMTP configuration (for sending status updates)
    SMTP_SERVER="smtp.gmail.com"
    SMTP_PORT=587
    RECIPIENT_EMAIL="notify_me@example.com"
    
    # Logging level and rotation
    LOG_LEVEL="INFO"
    LOG_MAX_BYTES=5242880
    LOG_BACKUP_COUNT=3
    
    # Abuse limits for the intake mailbox
    MAX_WAYBILLS_PER_EMAIL=10
    MAX_ACTIVE_PER_SENDER=25
    
    # Stop tracking waybills that never resolve, or stop changing (days)
    UNFOUND_EXPIRY_DAYS=7
    IDLE_EXPIRY_DAYS=30

    Note for Gmail users: you must use an App Password if 2-Step Verification is enabled. See the Configuration Guide for step-by-step instructions, and the Troubleshooting Guide if something doesn’t connect.

Usage

Run the tracker manually:

python Hytrack3.py

Automation (Cron Job)

To run the tracker on a schedule (every hour, for example), add a cron job:

crontab -e

Add the following line, adjusting the paths:

0 * * * * /path/to/HyTrackV3/.venv/bin/python /path/to/HyTrackV3/Hytrack3.py >> /path/to/HyTrackV3/cron.log 2>&1

A run that starts while the previous one is still going exits straight away, so overlapping cron runs are safe.

Project Structure

HyTrackV3/
├── .github/workflows/  # Tests (Python 3.12–3.14) and CodeQL
├── assets/             # README screenshots
├── docs/               # Configuration and troubleshooting guides
├── tests/              # Unit tests
├── Hytrack3.py         # Main application script
├── requirements.txt    # Python dependencies
├── sample.env.txt      # Template for environment variables
├── README.md           # Project documentation
└── hytrack3.db         # SQLite database (created on first run)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the GPL-3.0 License. See LICENSE for more information.