add agent workspace
This commit is contained in:
28
scripts/email_processor/move_ad_to_trash.py
Normal file
28
scripts/email_processor/move_ad_to_trash.py
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Move specific email to trash"""
|
||||
import imaplib
|
||||
import email
|
||||
|
||||
# Connect
|
||||
mail = imaplib.IMAP4_SSL('imap.migadu.com', 993)
|
||||
mail.login('youlu@luyanxin.com', 'kDkNau2r7m.hV!uk*D4Yr8mC7Dyjx9T')
|
||||
mail.select('INBOX')
|
||||
|
||||
# Search for the email with "10% off" in subject
|
||||
_, search_data = mail.search(None, 'SUBJECT', '"10% off"')
|
||||
email_ids = search_data[0].split()
|
||||
|
||||
print(f"Found {len(email_ids)} emails with '10% off' in subject")
|
||||
|
||||
for email_id in email_ids:
|
||||
# Copy to Trash
|
||||
result = mail.copy(email_id, 'Trash')
|
||||
if result[0] == 'OK':
|
||||
mail.store(email_id, '+FLAGS', '\\Deleted')
|
||||
print(f"✅ Moved email {email_id.decode()} to Trash")
|
||||
else:
|
||||
print(f"❌ Failed to move email {email_id.decode()}")
|
||||
|
||||
mail.expunge()
|
||||
mail.logout()
|
||||
print("Done!")
|
||||
Reference in New Issue
Block a user