簡體   English   中英

使用 IMAP4.uid Apple Mail 刪除:UID 命令錯誤

[英]Deleting with IMAP4.uid Apple Mail: UID command error

我正在嘗試恢復在 github 上找到的 python 2代碼,以清除我的 icloud 郵件。 我的代碼登錄,選擇 INBOX 並使用imaplib.IMAP4_ssl作為email_connection成功獲取狀態、ID 和 UID。

然后,它應該標記 Apple 的 icloud Mail 中的電子郵件以供刪除:

email_connection.uid("STORE", email_uid, "+FLAGS", "(\\Deleted)") 

但這是它拋出的地方

imaplib.error: UID command error: BAD [b'Parse Error (took 0 ms)']

原始代碼在同一位置使用了int(email_uid) ,我在它拋出時更改了它

TypeError: can't concat int to bytes

email_uid現在作為str傳遞,這會產生 UID 命令錯誤。 在線研究提供了很多特定於 gmail 的信息。 有人有在 Apple Mail 上使用 imaplib 的經驗嗎?

謝謝!

這是在中斷前幾行開始的調試日志:

    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)'

問題是雙重空間。

IMAP 對需要和允許空間的地方很嚴格。 只有在需要時才允許使用空格,並且只有在需要使用分隔符以避免誤解時才需要使用空格。 單個空格字符足以避免誤解,因此第二個空格是錯誤的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM