Error reading this code:

# coding: utf8 import imaplib,email M = imaplib.IMAP4_SSL('imap.mail.ru') M.login(nick, pass) M.select() typ, data = M.search(None, '(FROM "from@mail.ru")') for num in data[0].split(): typ, data = M.fetch(num, '(RFC3501)') raw = email.message_from_bytes(data[0][1]) print (raw.get_payload(None,True)) M.close() M.logout() 

Here is the error:

 FETCH command error: BAD [b'[PARSE] Range parse error'] 

    1 answer 1

    The error is returned not by the library, but by the server, since it cannot parse the IMAP fetch command parameter. And why are you transmitting '(RFC3501)' , what's the point of investing in this? I am not familiar with python and even less with its libraries, but according to the protocol description, the possible parameter value for getting the message body is the string 'RFC822' .

    • I just climbed the Internet in one post and saw what needed to be changed - Thread
    • What should be changed? You either accept the answer or give your answer, at least in the form of a full commentary on your question. - Outtruder
    • 'RFC822' by RFC3501 - Thread at 2:53 pm
    • Do you get an error with 'RFC822' too? - Outtruder 2:55 pm
    • Yes, with the first and second .. it depends on what parameter I pass to M.search (), when I transfer ALL - everything is fine, when FROM is such an error - Thread