44 lines
1.5 KiB
Python
44 lines
1.5 KiB
Python
import imaplib
|
|
|
|
# ==========================================
|
|
# 1. CONFIGURATION
|
|
# ==========================================
|
|
EMAIL_ADDRESS = "marti@agile611.com"
|
|
|
|
# ⚠️ Insert your generated App Password here (no spaces)
|
|
PASSWORD = "fcztyfdwpfrgqjgl" # Replace with your actual App Password
|
|
|
|
IMAP_SERVER = "outlook.office365.com"
|
|
IMAP_PORT = 993
|
|
|
|
def test_app_password_login():
|
|
print(f"🔌 Connecting to {IMAP_SERVER} on port {IMAP_PORT}...")
|
|
|
|
try:
|
|
# Connect to the server using SSL/TLS encryption
|
|
mail = imaplib.IMAP4_SSL(IMAP_SERVER, IMAP_PORT)
|
|
|
|
# Attempt plaintext login using the App Password
|
|
print("🔐 Attempting login with App Password...")
|
|
mail.login(EMAIL_ADDRESS, PASSWORD)
|
|
|
|
print("✅ Success! The App Password worked perfectly.")
|
|
|
|
# Select the inbox to verify we can read data
|
|
status, messages = mail.select("INBOX")
|
|
if status == "OK":
|
|
message_count = messages[0].decode('utf-8')
|
|
print(f"📥 INBOX selected successfully. Total messages: {message_count}")
|
|
|
|
# Safely log out
|
|
mail.logout()
|
|
print("👋 Logged out successfully.")
|
|
|
|
except imaplib.IMAP4.error as e:
|
|
print("\n❌ Login failed!")
|
|
print(f"Error details: {e}")
|
|
print("\n⚠️ Note: If you see 'BasicAuthBlocked' again, your organization's global Azure settings have completely disabled basic authentication, overriding the App Password.")
|
|
|
|
if __name__ == "__main__":
|
|
test_app_password_login()
|