Answer the question
In order to leave comments, you need to log in
Problems when trying to receive emails from pop.yandex.by?
def main(email, password):
pop = POP3_SSL("pop.yandex.by")
pop.user(email)
pop.pass_(password)
response, lst, octets = pop.list()
print(response, lst, octets)
for msgnum, msgsize in [i.split() for i in lst]:
(resp, lines, octets) = pop.retr(msgnum)# Ошибка возникает тут
msgtext = "n".join(lines) + "nn"
message = email.message_from_string(msgtext)
print(message)
pop.dele(msgnum)
pop.quit()
b'+OK 1 19430' [b'1 19430'] 9
Traceback (most recent call last):
File "C:\Users\FFF\Desktop\kkk\main.py", line 89, in <module>
main(*data)
File "C:\Users\FFF\Desktop\kkk\main.py", line 79, in main
(resp, lines, octets) = pop.retr(msgnum)
File "C:\Users\FFF\AppData\Local\Programs\Python\Python36\lib\poplib.py", line 248, in retr
return self._longcmd('RETR %s' % which)
File "C:\Users\FFF\AppData\Local\Programs\Python\Python36\lib\poplib.py", line 183, in _longcmd
return self._getlongresp()
File "C:\Users\FFF\AppData\Local\Programs\Python\Python36\lib\poplib.py", line 159, in _getlongresp
resp = self._getresp()
File "C:\Users\FFF\AppData\Local\Programs\Python\Python36\lib\poplib.py", line 152, in _getresp
raise error_proto(resp)
poplib.error_proto: b'-ERR message does not exist or deleted. sc=XnamNVYWfOs1_102349_1-4aab5eef9bfd'
Answer the question
In order to leave comments, you need to log in
The trick is that msgnum is represented in byte, but it should be in int, that's the whole point.
def main(email, password):
pop = POP3_SSL("pop.yandex.by")
pop.user(email)
pop.pass_(password)
response, lst, octets = pop.list()
print(response, lst, octets)
for msgnum, msgsize in [i.split() for i in lst]:
(resp, lines, octets) = pop.retr(int(msgnum))
msgtext = "n".join(lines) + "nn"#Нужно отлаживать, тут бред происходит
message = email.message_from_string(msgtext)# тут тоже
print(message)
pop.dele(int(msgnum))
pop.quit()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question