import argparse
import re
import dns.resolver
import httpx
from typing import Tuple, Optional, List, Dict

def validate_email_syntax(email: str) -> bool:
    """
    Validate the syntax of an email address using a regular expression.

    Args:
        email (str): The email address to validate.

    Returns:
        bool: True if the email syntax is valid, False otherwise.
    """
    pattern = r'^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$'
    return re.match(pattern, email) is not None

def check_mx_records(domain: str) -> bool:
    """
    Check if the domain has valid MX (Mail Exchange) records.

    Args:
        domain (str): The domain part of the email address.

    Returns:
        bool: True if MX records exist, False otherwise.
    """
    try:
        records = dns.resolver.resolve(domain, 'MX')
        return bool(records)
    except (dns.resolver.NoAnswer, dns.resolver.NXDOMAIN, dns.exception.Timeout):
        return False

def is_disposable_email(email: str) -> bool:
    """
    Check if the email domain is a disposable email provider.

    Args:
        email (str): The email address to check.

    Returns:
        bool: True if the domain is disposable, False otherwise.
    """
    domain = email.split('@')[1]
    # List of known disposable email domains (simplified for example)
    disposable_domains = [
        'mailinator.com', 'tempmail.com', 'guerrilla-mail.com', 'disposablemail.com'
    ]
    return domain in disposable_domains

def get_email_confidence(email: str) -> Tuple[int, str]:
    """
    Calculate a confidence score for the email address.

    Args:
        email (str): The email address to evaluate.

    Returns:
        Tuple[int, str]: A tuple containing the confidence score (0-100) and a message.
    """
    if not validate_email_syntax(email):
        return 0, "Invalid email syntax"
    
    domain = email.split('@')[1]
    if not check_mx_records(domain):
        return 50, "MX records not found, potential invalid domain"
    
    if is_disposable_email(email):
        return 30, "Disposable email domain detected"
    
    return 100, "Valid and trustworthy email address"

def main():
    """
    Main function to run the email validator script.
    """
    parser = argparse.ArgumentParser(description="Email Validator: Check email syntax, MX records, and disposable domains.")
    parser.add_argument("email", type=str, help="Email address to validate")
    parser.add_argument("--help", action="help", help="Show this help message and exit")
    args = parser.parse_args()

    confidence, message = get_email_confidence(args.email)
    print(f"Email: {args.email}")
    print(f"Confidence: {confidence}%")
    print(f"Status: {message}")

if __name__ == '__main__':
    main()