Skip to content

IMAPClient ssl.SSLEOFError: EOF occurred in violation of protocol #614

@risingwolf21

Description

@risingwolf21

I am using th IMAPClient to read Emails in shared mail folder. My workflow looks like this:

server = IMAPClient(host=***, port=***)
server.login(username=***, password=***)
server.select_folder('Other Users/***')

That is my login and folder selection. This is wrapped in a function and returns the server object.
Afterwards I use a cron job to read the emails every 15 minutes in my flask application.

messages = self.imap_server.search()
print(f"{len(messages)} emails found")
if len(messages) == 0:
   return []
items = self.imap_server.fetch(messages, 'RFC822').items()
messages = [(uid, email.message_from_bytes(data[b"RFC822"])) for uid, data in items]
return [Email.from_message(uid, m) for uid, m in messages]

That is the exception I get:

File "/app/server/emails/imap_client.py", line 29, in read_emails

    messages = self.imap_server.search()

               ^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/platform/venv/lib/python3.12/site-packages/imapclient/imapclient.py", line 1122, in search

    return self._search(criteria, charset)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/platform/venv/lib/python3.12/site-packages/imapclient/imapclient.py", line 1148, in _search

    data = self._raw_command_untagged(b"SEARCH", args)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/platform/venv/lib/python3.12/site-packages/imapclient/imapclient.py", line 1656, in _raw_command_untagged

    typ, data = self._raw_command(command, args, uid=uid)

                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/platform/venv/lib/python3.12/site-packages/imapclient/imapclient.py", line 1714, in _raw_command

    self._imap.send(out)

  File "/usr/platform/venv/lib/python3.12/site-packages/imapclient/tls.py", line 65, in send

    self.sock.sendall(data)

  File "/usr/local/lib/python3.12/ssl.py", line 1210, in sendall

    v = self.send(byte_view[count:])

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib/python3.12/ssl.py", line 1179, in send

    return self._sslobj.write(data)

           ^^^^^^^^^^^^^^^^^^^^^^^^

ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:2427)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions