Unable to download IMAP mail

Hello, until a year ago my mails were correctly grabbed by mayan, after that I maybe upgraded to a new version and didn’t noticed it was not working anymore. I saw many changes in the settings, that I corrected, adding credentials.
Now it seems that Mayan connects correctly to the server, I don’t receive errors in logs for the connection, but I get this error while connecting

[2024-08-26 09:57:19,850: ERROR/ForkPoolWorker-30] Error processing source id: 4; Error executing search command; command SEARCH illegal in state AUTH, only allowed in states SELECTED
Traceback (most recent call last):
  File "/opt/mayan-edms/lib/python3.11/site-packages/mayan/apps/source_emails/source_backends/imap_source_backends.py", line 225, in get_stored_file_list
    status, data = server.uid(
                   ^^^^^^^^^^^
  File "/usr/lib/python3.11/imaplib.py", line 885, in uid
    raise self.error("command %s illegal in state %s, "
imaplib.IMAP4.error: command SEARCH illegal in state AUTH, only allowed in states SELECTED
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/opt/mayan-edms/lib/python3.11/site-packages/mayan/apps/sources/tasks.py", line 74, in task_source_backend_action_execute
    action.execute(
  File "/opt/mayan-edms/lib/python3.11/site-packages/mayan/apps/sources/source_backend_actions/base.py", line 141, in execute
    execute_kwargs = interface_instance.load(**interface_load_kwargs)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/mayan-edms/lib/python3.11/site-packages/mayan/apps/sources/source_backend_actions/interfaces.py", line 108, in load
    self.process_interface_context()
  File "/opt/mayan-edms/lib/python3.11/site-packages/mayan/apps/source_compressed/source_backend_actions/mixins.py", line 199, in process_interface_context
    super().process_interface_context()
  File "/opt/mayan-edms/lib/python3.11/site-packages/mayan/apps/source_stored_files/source_backend_actions/mixins.py", line 381, in process_interface_context
    self.action_kwargs['file_identifier'] = source_backend_instance.get_file_identifier()
                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/mayan-edms/lib/python3.11/site-packages/mayan/apps/source_emails/source_backends/mixins.py", line 148, in get_file_identifier
    file_list_generator = list(file_list_generator)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/mayan-edms/lib/python3.11/site-packages/mayan/apps/source_emails/source_backends/imap_source_backends.py", line 229, in get_stored_file_list
    raise SourceException(
mayan.apps.sources.exceptions.SourceException: Error executing search command; command SEARCH illegal in state AUTH, only allowed in states SELECTED

In order to narrow down the source of the issue, what were the versions before and after the upgrade?

I’m trying to figure out what the problems is.
I actually managed to get IMAP working, from the interface is not totally clear where Mayan will take the email address, for what I think is using the username in credential as email address, and the IMAP box field in IMAP protocol is the folder, so INBOX by default.
My previous error was because I set in the IMAP box the mail address.
Now when I hit test actually just one email is grabbed with an error:

mayan.apps.converter.backends.python <258> [ERROR] "get_pillow_page_count() line 107 Exception determining page count using Pillow; cannot identify image file <File: /var/lib/mayan/document_file_storage/1f8e9681-277b-4b38-bdf2-f5ea852b92fd>"
[2024-08-26 20:27:45,486: ERROR/ForkPoolWorker-1] Exception determining page count using Pillow; cannot identify image file <File: /var/lib/mayan/document_file_storage/1f8e9681-277b-4b38-bdf2-f5ea852b92fd>

This happens for every mail it receive.
But it seems now it’s getting the emails correctly, also if just one at time, and the error above don’t make any issues in the documents.