clawd/minimal_imap_test.py

36 lines
1023 B
Python

#!/usr/bin/env python3
import imaplib
import ssl
import socket
def test_minimal():
try:
print("Creating SSL socket...")
context = ssl.create_default_context()
context.check_hostname = False
context.verify_mode = ssl.CERT_NONE
# Test raw socket connection first
print("Testing raw socket connection...")
sock = socket.create_connection(('localhost', 9930), timeout=10)
print("Raw socket connected!")
# Wrap with SSL
print("Wrapping with SSL...")
ssl_sock = context.wrap_socket(sock, server_hostname='localhost')
print("SSL handshake successful!")
# Test IMAP greeting
print("Reading IMAP greeting...")
greeting = ssl_sock.recv(1024)
print(f"Greeting: {greeting}")
ssl_sock.close()
except Exception as e:
print(f"Error: {e}")
import traceback
traceback.print_exc()
if __name__ == "__main__":
test_minimal()