I'm trying to revive a python 2 code that I found on github to clean out my icloud mails. My code logs in, selects INBOX and fetches status, IDs and UIDs successfully using imaplib.IMAP4_ssl
as email_connection
.
It, then, should flag emails in Apple's icloud Mail for deletion:
email_connection.uid("STORE", email_uid, "+FLAGS", "(\\Deleted)")
but this is where it throws an
imaplib.error: UID command error: BAD [b'Parse Error (took 0 ms)']
The original code used int(email_uid)
at the same spot which I changed as it threw
TypeError: can't concat int to bytes
email_uid
is now passed as a str
which produces the UID command error. Online research gave a lot of info that was gmail-specific.
Anyone with experience of using imaplib on Apple Mail?
Thanks!
Here is the debug log starting a few lines before the break:
06:34.78 < b'* 198 FETCH (UID 47520)'
06:34.78 matched b'\\* (?P<data>\\d+) (?P<type>[A-Z-]+)( (?P<data2>.*))?' => (b'198', b'FETCH', b' (UID 47520)', b'(UID 47520)')
06:34.78 untagged_responses[FETCH] 0 += ["b'198 (UID 47520)'"]
06:34.78 < b'IAFG4 OK FETCH completed (took 52 ms)'
06:34.78 matched b'(?P<tag>IAFG\\d+) (?P<type>[A-Z]+) (?P<data>.*)' => (b'IAFG4', b'OK', b'FETCH completed (took 52 ms)')
06:34.78 untagged_responses[FETCH] => [b'198 (UID 47520)']
06:34.78 > b'IAFG5 UID STORE 47520 +FLAGS (\\Deleted)'
06:34.89 < b'IAFG5 BAD Parse Error (took 0 ms)'
06:34.89 matched b'(?P<tag>IAFG\\d+) (?P<type>[A-Z]+) (?P<data>.*)' => (b'IAFG5', b'BAD', b'Parse Error (took 0 ms)')
06:34.89 BAD response: b'Parse Error (took 0 ms)'