Skip to main content

phishdetect

Email phishing and spam detection library — drop it into any Python project or run it as a standalone REST API on your mail server.

Install

pip install phishdetect

Use as a Python library

from phishdetect import PhishingDetector

detector = PhishingDetector()

result = detector.analyze({
    "sender":   "support@paypa1.com",
    "subject":  "Urgent: verify your account NOW!!",
    "content":  "Click here to reset your password immediately.",
    "reply_to": "",   # optional
})

print(result["risk_score"])   # "HIGH", "MEDIUM", or "LOW"
print(result["risk_level"])   # 0–100 numeric score
print(result["warnings"])     # detailed list of every signal found

Integrate with your mail server

from phishdetect import PhishingDetector

detector = PhishingDetector()

def on_email_received(email):
    result = detector.analyze({
        "sender":  email.from_address,
        "subject": email.subject,
        "content": email.body,
    })

    if result["risk_score"] == "HIGH":
        quarantine(email)
    elif result["risk_score"] == "MEDIUM":
        add_warning_banner(email)
    else:
        deliver(email)

Run as a REST API server

phishdetect-server
# Server starts at http://0.0.0.0:5000

API endpoints

Method Endpoint Description
POST /analyze Analyze an email for phishing
GET /health Health check
GET /status Domain intelligence database info
POST /update Refresh the Tranco domain list

Example API call

curl -X POST http://localhost:5000/analyze \
  -H "Content-Type: application/json" \
  -d '{
    "sender":  "support@paypa1.com",
    "subject": "Urgent: verify your account",
    "content": "Click here to reset your password."
  }'

What it detects

  • Lookalike domains — paypa1.com vs paypal.com (Levenshtein distance)
  • Homoglyph attacks — Unicode characters that look like Latin letters (е, о, а)
  • Subdomain abuse — paypal.attacker.com pretending to be PayPal
  • Suspicious keywords — urgency, financial fraud, prize/lottery patterns
  • Deceptive links — visible URL differs from actual href destination
  • Reply-To mismatch — replies routed to a different domain
  • New domains — recently registered domains flagged via WHOIS
  • Spam signals — ALL CAPS subjects, excessive exclamation marks, bulk patterns

How the domain database works

On first run, phishdetect automatically downloads the Tranco top-1M domain list and stores the top 50,000 domains in a local SQLite database at ~/.phishdetect/phishing.db. This refreshes weekly. No API key required.

License

MIT

Metadata

Release files for phishguard 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for phishguard 1.0.1
File Size Uploaded Provenance Actions
phishguard-1.0.1.tar.gz 13.2 kB Without provenance Details for phishguard-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for phishguard 1.0.1
File Interpreter ABI Platform Actions
phishguard-1.0.1-py3-none-any.whl Python 3 none any Details for phishguard-1.0.1-py3-none-any.whl

Total release size: 26.7 kB

Release files / phishguard-1.0.1.tar.gz

Download URL phishguard-1.0.1.tar.gz
Size 13.2 kB
Tags Source
SHA-256 checksum
How to use checksums
6423758e22f49c6d714b30f6332f0b20bc633e30b19d57eddcab8264b56d1272
BLAKE2b-256 checksum
How to use checksums
3ee240c4816c8af59ddc6d360334be3b75ee2e5f485475ec9f6530e9ee8826da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / phishguard-1.0.1-py3-none-any.whl

Download URL phishguard-1.0.1-py3-none-any.whl
Size 13.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a9357957dc0cd075834deb2fe75eb86ac5aff296aa5a3465e65efde35ad5ed50
BLAKE2b-256 checksum
How to use checksums
5762e2c07c53cf647ca430854de2508d58f4df3003ebaa5474df96d65b95b946
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Security for phishguard 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page