Is this line you read for the limit ?
imaplib._MAXLINE = 20480
I think it’s a limit of length for one line and not a limit for all the content.
Here a documentation
# reading arbitrary length lines. RFC 3501 and 2060 (IMAP 4rev1)
# don't specify a line length. RFC 2683 however suggests limiting client
# command lines to 1000 octets and server command lines to 8000 octets.
# We have selected 10000 for some extra margin and since that is supposedly
# also what UW and Panda IMAP does.
_MAXLINE = 10000
So it’s not a problem.