Search code examples
pythonimap

How to limit imap search/uid fetches


In order to avoid

imaplib.error: command: UID => got more than 10000 bytes

I would like to fetch only a specific number of mails or requesting the number of search matches, without throwing an exception.

Is the only way how i can handle this problem, reducing the SINCE BEFORE interval on every exception, until i reach the first or last mail?

Editing _MAXLINE would only affect my environment and isn't helpful in this case.


Solution

  • The only solution is to reduce SINCE/BEFORE, or its equivalent.

    Will you submit a patch for python's imaplib, or shall I? We can't leave this forever.