-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_email.py
More file actions
33 lines (26 loc) · 1003 Bytes
/
Copy pathtest_email.py
File metadata and controls
33 lines (26 loc) · 1003 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""Quick test of email connection with multiple senders."""
import imaplib
HOST = "imap.gmail.com"
USER = "lovelykimura832@gmail.com"
PASSWORD = "ztrv pndd qslg jtsh"
FROM_FILTERS = ["s1963@yandex.ru", "nsv11061992@gmail.com"]
print(f"Connecting to {HOST}...")
try:
mail = imaplib.IMAP4_SSL(HOST)
mail.login(USER, PASSWORD)
print("✅ Login successful!")
mail.select("INBOX")
total = 0
for sender in FROM_FILTERS:
_, messages = mail.search(None, f'(FROM "{sender}")')
count = len(messages[0].split()) if messages[0] else 0
print(f"📧 {sender}: {count} писем")
total += count
print(f"\n📊 Всего: {total} писем от обоих адресов")
if total > 0:
print("✅ Готово к работе!")
else:
print("⚠️ Отправь тестовое письмо с одного из адресов.")
mail.logout()
except Exception as e:
print(f"❌ Error: {e}")