import paramiko

HOST = "135.125.102.180"
USER = "ubuntu"
PASS = "BotPascal2026!"
REMOTE_BASE = "/var/www/html/repondeur_mail_grok"

def main():
    try:
        ssh = paramiko.SSHClient()
        ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        ssh.connect(HOST, username=USER, password=PASS)
        
        print("🔍 Testing scan.php on VPS...")
        # Run with limit 0 or 1 just to check for fatals (though limit 0 might do nothing, let's try 1)
        # We handle output.
        stdin, stdout, stderr = ssh.exec_command(f"php {REMOTE_BASE}/scripts/scan.php 1")
        
        out = stdout.read().decode()
        err = stderr.read().decode()
        
        print(f"STDOUT:\n{out}")
        print(f"STDERR:\n{err}")
        
        if "undefined function imap_open" in err:
            print("❌ FAILURE: imap_open still missing.")
        elif "Fatal error" in err:
            print("❌ FAILURE: Script crashed.")
        else:
            print("✅ SUCCESS: Script ran (or at least didn't crash on imap_open).")
            
        ssh.close()
    except Exception as e:
        print(f"❌ Error: {e}")

if __name__ == "__main__":
    main()
