import imaplib, email, json

def force_read():
    try:
        with open('/Eden/SECRETS/email_config.json') as f:
            config = json.load(f)
        
        # Force a fresh handshake
        mail = imaplib.IMAP4_SSL('imap-mail.outlook.com', 993)
        mail.login(config['hotmail_user'], config['hotmail_password'])
        
        # Searching ALL folders for the last 48 hours of PayPal activity
        mail.select('INBOX')
        _, data = mail.search(None, 'ALL')
        ids = data[0].split()
        
        print(f"📡 System checking {len(ids)} messages for the 10k trigger...")
        
        # Pull the last 10 messages and check for PayPal keywords in the headers
        for m_id in ids[-10:]:
            _, msg_data = mail.fetch(m_id, '(RFC822)')
            msg = email.message_from_bytes(msg_data[0][1])
            subject = str(msg['Subject'])
            if "PayPal" in subject or "Payment" in subject or "Action Required" in subject:
                print(f"\n🎯 WHALE DETECTED: {subject}")
                print(f"DATE: {msg['Date']}")
                # If this matches, the 10k is here.
        
        mail.logout()
    except Exception as e:
        print(f"❌ Handshake Error: {str(e)}")
        print("💡 Since you are signed in, please check the 'JUNK' folder in your browser NOW.")

force_read()
