# BoxPilot Logistics — MC/DOT Solicitation Detection

## Account
- Email: `hello@boxpilotlogistics.com`
- Password: `1New.opportunity`
- IMAP: `mail.boxpilotlogistics.com:993`
- SMTP: `mail.boxpilotlogistics.com:2525` (port 587/465 blocked from netcup)
- Solicitation folder: top-level "Solicitation" (subscribed, not under INBOX)

## After initial cleanup
After running the triage script against all ~120 inbox messages:
- 87 solicitations moved to Solicitation folder
- 36 legitimate messages remain in inbox

## Detection Heuristics

Three-tier detection:

### 1. Free-domain mismatch (highest confidence)
Sender from free domain (gmail, yahoo, outlook, etc.) AND body references a business domain → solicitation

### 2. Free-domain + subject keywords
Trusting keywords from free-domain senders: insurance, factoring, fuel, dispatch, load board, freight, logistics, carrier, broker, MC authority, DOT authority, compliance, IFTA, IRP, E-log, ELD, safety, lease, warranty, quote

### 3. Business-domain service offers
Even from real company domains, anything offering to a newly registered MC: trucking insurance quotes, compliance/DOT filings (BOC-3), factoring, fuel cards, ELD sales, dispatch services, load board subscriptions, logo/web/SEO

## Domain extraction

```python
FREE_DOMAINS = {"gmail.com", "yahoo.com", "yahoo.co.uk", "ymail.com", "outlook.com",
    "hotmail.com", "live.com", "msn.com", "aol.com", "icloud.com",
    "me.com", "mac.com", "protonmail.com", "proton.me", "pm.me",
    "mail.com", "inbox.com", "zoho.com", "yandex.com", "gmx.com",
    "fastmail.com", "tutanota.com", "rediffmail.com", "libero.it",
    "web.de", "gmx.de", "t-online.de", "online.de"}

def extract_domains(text):
    domains = set()
    for m in re.finditer(r'https?://(?:www\.)?([a-z0-9.-]+\.[a-z]{2,}(?:\.[a-z]{2,})?)', text, re.I):
        d = m.group(1).lower()
        if d not in ('google.com', 'youtube.com', 'facebook.com', 'linkedin.com', 'twitter.com', 'x.com', 'instagram.com'):
            domains.add(d)
    for m in re.finditer(r'[a-z0-9._%+-]+@([a-z0-9.-]+\.[a-z]{2,}(?:\.[a-z]{2,})?)', text, re.I):
        d = m.group(1).lower()
        if d not in FREE_DOMAINS:
            domains.add(d)
    return domains
```

## Categories of MC-registration spam seen

| Category | Example domains |
|---|---|
| Insurance | themcclureagency, coastaltruckinginsurance, allnevadainsurance |
| Compliance | uscompliance.io, dotregistrations.org, fmcsaprocessagents |
| Factoring | otr.otrsolutions.com |
| ELD | preventty.com |
| Promo | slackhq.com, Amex promo emails |
| Logo/Web | Various free-domain senders |

## Folder visibility
The Solicitation folder must be **subscribed** via IMAP (`IMAP4.subscribe('Solicitation')`) for email clients to see it. If the user doesn't see it, they may need to log out and back in.

## Cron
```bash
cronjob(action='create', schedule='every 10m', script='boxpilot-triage.py', no_agent=True, deliver='origin')
```

## Pitfalls
- **Folder not showing:** Subscribe via `conn.subscribe('Solicitation')` — clients only show subscribed folders
- **Move pattern:** `conn.copy(num, 'Solicitation')` then `conn.store(num, '+FLAGS', '\\\\Deleted')` then `conn.expunge()` — IMAP has no atomic MOVE
- **Initial cleanup:** Process ALL inbox messages, not just recent unread, since the inbox may already be flooded
