I am trying to read emails using the poplib library but getting an error - poplib.error_proto: -ERR EOF. The initial connection seems to be successful and I am able to get the response for the getwelcome() function but after that, the server seems to be closing the connection. Adding the code below, nothing special just the dummy code -
import poplib
client = poplib.POP3_SSL(server_name, port)
client.user(username)
client.pass_(password)
welcome = client.getwelcome()
print(welcome)
messages = len(client.list()[1]) # throws error - poplib.error_proto: -ERR EOF
Traceback (most recent call last):
File "email-pop.py", line 68, in <module>
fetch_all_mails()
File "email-pop.py", line 36, in fetch_all_mails
numMessages = len(pop_conn.list()[1])
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/poplib.py", line 243, in list
return self._longcmd('LIST')
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/poplib.py", line 186, in _longcmd
return self._getlongresp()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/poplib.py", line 162, in _getlongresp
resp = self._getresp()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/poplib.py", line 152, in _getresp
resp, o = self._getline()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/poplib.py", line 136, in _getline
if not line: raise error_proto('-ERR EOF')
poplib.error_proto: -ERR EOF
Can't seem to find what could be the issue, any help would be appreciated. Thanks