A clean inbox is a sharp mind. Spamurai is here to forge the blade.
🚀 Project Status: Actively under development
Clone & run the main script:
git clone https://github.com/nakuldevmv/Spamurai.git
cd Spamurai/backendThe entry point is backend/index.js.
Spamurai is your digital bushido—a script that slices through spam like a katana through chaos. It:
- Fetches mail via IMAP (Gmail ready)
- Auto‑detects & clicks unsubscribe links 🪄
- Moves unwanted mail to Trash (or nukes it ☠️)
- Logs every strike to MongoDB Atlas
- Node.js (v16+)
- npm or yarn
- MongoDB Atlas cluster
- Google App Password (for IMAP access)
- IPQualityScore API key (for link safety checks)
Copy the example environment file and fill in your own values:
cp example.env .envFill out .env like this:
# Gmail IMAP (App Password)
EMAIL='you@gmail.com'
PASSWORD='your_16_digit_app_password'
PORT=993
HOST='imap.gmail.com'
# URL safety scanner (IPQualityScore)
IPQ_API='your_ipqs_api_key'
# MongoDB Atlas
DB_USERNAME='your_db_user'
DB_PASSWORD='your_db_password'
CLUSTER='your_cluster_url'   # e.g. spamurai.gjpxkae.mongodb.net
DB_NAME='spamurai'
DB_COLLECTION='scanned_links'
DB_COLLECTION2='unsubedLink'🔒 Never commit your real
.env—keep it in.gitignore.
# from Spamurai/backend
npm install      # or yarn install
npm start        # or node index.js- IMAP Connect — Logs into your Gmail inbox
- Filter — Skips flagged or important mail
- Extract — Finds unsubscribe links in each email
- Verify — Checks links via IPQualityScore (or cache)
- Execute — Clicks safe links, logs to MongoDB
- Cleanup — Moves processed messages to Trash (optional delete)
- Spamurai is still in training—no warranties.
- It only clicks links marked safe.
- Double‑check your .envbefore you run.
- Backup your inbox if you’re feeling paranoid.
flowchart TD
    subgraph "Spamurai Service"
        ORC["Orchestrator (backend/index.js)"]:::internal
        CFG["Configuration (.env)"]:::internal
        IMAP["IMAP Connector"]:::internal
        PARS["Mail Filter & Parser (getters.js)"]:::internal
        subgraph "Unsubscribe Module"
            FIND["Unsubscribe Link Extractor (findUnsubLinks.js)"]:::internal
            PUPP["Puppeteer Setup (pupSetup.js)"]:::internal
        end
        SCAN["Link Safety Scanner (ipqs.js)"]:::internal
        subgraph "Unsubscriber Service"
            UNS["Unsubscriber Logic (unsubscriber.js)"]:::internal
            CAPTCHA["Captcha Handler (captcha.js)"]:::internal
        end
        CLEAN["Mail Cleanup (imap-copy.js)"]:::internal
        MONGO_CLIENT["Logger / Persistence (mongoConnect.js)"]:::internal
    end
    IMAP_SRV[("IMAP Server")]:::external
    IPQS[("IPQualityScore API")]:::external
    MONGO[("MongoDB Atlas")]:::db
    ORC --> CFG
    ORC --> IMAP
    IMAP --> IMAP_SRV
    ORC --> PARS
    PARS --> FIND
    FIND --> SCAN
    SCAN -->|"safe"| PUPP
    PUPP --> UNS
    SCAN -->|"POST /check"| IPQS
    SCAN --> MONGO_CLIENT
    UNS -->|"click safe links"| MONGO_CLIENT
    UNS --> CLEAN
    CLEAN --> IMAP_SRV
    MONGO_CLIENT --> MONGO
    CFG -.-> ORC
    CFG -.-> IMAP
    CFG -.-> PARS
    CFG -.-> FIND
    CFG -.-> SCAN
    CFG -.-> UNS
    CFG -.-> CLEAN
    CFG -.-> MONGO_CLIENT
    click ORC "https://github.com/nakuldevmv/spamurai/blob/main/backend/index.js"
    click IMAP "https://github.com/nakuldevmv/spamurai/blob/main/backend/utils/connectMail/imapConnect.js"
    click PARS "https://github.com/nakuldevmv/spamurai/blob/main/backend/utils/getters.js"
    click FIND "https://github.com/nakuldevmv/spamurai/blob/main/backend/utils/unsub/findUnsubLinks.js"
    click PUPP "https://github.com/nakuldevmv/spamurai/blob/main/backend/utils/unsub/pupSetup.js"
    click SCAN "https://github.com/nakuldevmv/spamurai/blob/main/backend/utils/scanners/ipqs.js"
    click UNS "https://github.com/nakuldevmv/spamurai/blob/main/backend/utils/unsub/unsubscriber.js"
    click CAPTCHA "https://github.com/nakuldevmv/spamurai/blob/main/backend/utils/unsub/captcha.js"
    click CLEAN "https://github.com/nakuldevmv/spamurai/blob/main/backend/utils/connectMail/imap-copy.js"
    click MONGO_CLIENT "https://github.com/nakuldevmv/spamurai/blob/main/backend/utils/server/mongoConnect.js"
    click CFG "https://github.com/nakuldevmv/spamurai/blob/main/backend/example.env"
    classDef internal fill:#0E4C75,stroke:#5DADE2
    classDef external fill:#2C3E50,stroke:#95A5A6
    classDef db fill:#145A32,stroke:#58D68D
    - Smarter unsubscribe link detection
- Advanced link‑safety heuristics & fallbacks
- A Simple UI for I/O
- OAuth2 support for Gmail (drop app passwords)
- Whitelist VIP senders to avoid friendly fire
- Helpful docs:
Spamurai bows, sheaths the blade, and fades into the shadows...