verified_user

code Python verified Free Download devices Cross-platform

code Code Preview

Python
#!/usr/bin/env python3
"""
Sender Reputation Checker
Check DNS records and reputation status for email domains
"""
import dns.resolver
import socket

def check_sender_reputation(domain):
    """Check domain reputation and email configuration"""
    report = {
        'domain': domain,
        'ip': None,
        'spf': 'Not configured',
        'dkim': 'Not checked',
        'dmarc': 'Not configured',
        'mx': [],
        'score': 0
    }

    # Get IP address
    try:
        report['ip'] = socket.gethostbyname(domain)
        report['score'] += 10
    except socket.gaierror:
        report['ip'] = 'Unable to resolve'

    # Check MX records
    try:
        mx_records = dns.resolver.resolve(domain, 'MX')
        report['mx'] = [str(r.exchange) for r in mx_records]
        report['score'] += 20
    except:
        report['mx'] = []

    # Check SPF record
    try:
        txt_records = dns.resolver.resolve(domain, 'TXT')
        for record in txt_records:
            if 'v=spf1' in str(record):
                report['spf'] = 'Configured'
                report['score'] += 25
                break
    except:
        pass

    # Check DMARC record
    try:
        dmarc = dns.resolver.resolve(f'_dmarc.{domain}', 'TXT')
        for record in dmarc:
            if 'v=DMARC1' in str(record):
                report['dmarc'] = 'Configured'
                report['score'] += 25
                break
    except:
        pass

    # Check DKIM (common selectors)
    selectors = ['default', 'google', 'selector1', 'selector2']
    for selector in selectors:
        try:
            dkim = dns.resolver.resolve(f'{selector}._domainkey.{domain}', 'TXT')
            report['dkim'] = f'Found ({selector})'
            report['score'] += 20
            break
        except:
            continue

    return report

def get_reputation_grade(score):
    """Convert score to letter grade"""
    if score >= 90:
        return 'A', 'Excellent'
    elif score >= 70:
        return 'B', 'Good'
    elif score >= 50:
        return 'C', 'Fair'
    elif score >= 30:
        return 'D', 'Poor'
    else:
        return 'F', 'Critical'

if __name__ == '__main__':
    import sys
    domain = sys.argv[1] if len(sys.argv) > 1 else 'example.com'
    report = check_sender_reputation(domain)
    grade, status = get_reputation_grade(report['score'])
    print(f"Domain: {report['domain']}")
    print(f"Grade: {grade} ({status})")
    print(f"SPF: {report['spf']}")
    print(f"DMARC: {report['dmarc']}")
    print(f"DKIM: {report['dkim']}")

info About This Tool

The Sender Reputation Checker analyzes your domain's email configuration and calculates a reputation score based on SPF, DKIM, DMARC, and DNS settings.

Checks Performed

  • SPF Record - Validates sender authorization
  • DKIM - Checks for signing keys
  • DMARC - Verifies policy configuration
  • MX Records - Confirms mail server setup
  • IP Resolution - Verifies DNS health

Reputation Grades

  • A (90+) - Excellent, all systems configured
  • B (70-89) - Good, minor improvements possible
  • C (50-69) - Fair, missing some records
  • D (30-49) - Poor, significant issues
  • F (<30) - Critical, deliverability at risk

Requirements

  • Python 3.7+
  • dnspython (pip install dnspython)

Tip: Run this check before starting any email campaign to ensure maximum deliverability.

download Download Script

Need Full Automation?

Try Postigo for automated email campaigns with AI personalization

rocket_launch Start Free Trial