jonaswinkler / paperless-ng

A supercharged version of paperless: scan, index and archive all your physical documents
https://paperless-ng.readthedocs.io/en/latest/
GNU General Public License v3.0
5.37k stars 356 forks source link

[BUG] Task paperless_mail.tasks.process_mail_accounts errors if no port is given #1557

Open pyfisch opened 2 years ago

pyfisch commented 2 years ago

Describe the bug Exception occurs during the execution of task process mail accounts if no explicit port is chosen.

To Reproduce Steps to reproduce the behavior:

  1. Add a new email account, set all required fields and choose "SSL encryption", but don't set the IMAP port.
  2. Wait for task paperless_mail.tasks.process_mail_accounts to execute
  3. Look up failed tasks in the admin interface, find the most recent execution
  4. See error below

Expected behavior Paperless-ng chooses automatically port 143 for unencrypted/STARTLS and port 993 for SSL if the port isn't explicitly given.

Webserver logs


[Errno 99] Cannot assign requested address : Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/django_q/cluster.py", line 432, in worker
res = f(*task["args"], **task["kwargs"])
File "/usr/src/paperless/src/paperless_mail/tasks.py", line 14, in process_mail_accounts
total_new_documents += MailAccountHandler().handle_mail_account(
File "/usr/src/paperless/src/paperless_mail/mail.py", line 157, in handle_mail_account
with get_mailbox(account.imap_server,
File "/usr/src/paperless/src/paperless_mail/mail.py", line 97, in get_mailbox
mailbox = MailBox(server, port)
File "/usr/local/lib/python3.9/site-packages/imap_tools/mailbox.py", line 290, in __init__
super().__init__()
File "/usr/local/lib/python3.9/site-packages/imap_tools/mailbox.py", line 32, in __init__
self.box = self._get_mailbox_client()
File "/usr/local/lib/python3.9/site-packages/imap_tools/mailbox.py", line 307, in _get_mailbox_client
return imaplib.IMAP4_SSL(self._host, self._port, self._keyfile, # noqa
File "/usr/local/lib/python3.9/imaplib.py", line 1324, in __init__
IMAP4.__init__(self, host, port, timeout)
File "/usr/local/lib/python3.9/imaplib.py", line 202, in __init__
self.open(host, port, timeout)
File "/usr/local/lib/python3.9/imaplib.py", line 1337, in open
IMAP4.open(self, host, port, timeout)
File "/usr/local/lib/python3.9/imaplib.py", line 312, in open
self.sock = self._create_socket(timeout)
File "/usr/local/lib/python3.9/imaplib.py", line 1327, in _create_socket
sock = IMAP4._create_socket(self, timeout)
File "/usr/local/lib/python3.9/imaplib.py", line 302, in _create_socket
return socket.create_connection(address)
File "/usr/local/lib/python3.9/socket.py", line 843, in create_connection
raise err
File "/usr/local/lib/python3.9/socket.py", line 831, in create_connection
sock.connect(sa)
OSError: [Errno 99] Cannot assign requested address

Relevant information

henfri commented 2 years ago

I con firm this bug, although it was for me: TimeoutError: [Errno 110] Connection timed out

pyfisch commented 2 years ago

@henfri I use Paperless-ng with Docker, I suspect you aren't based on the error. Is that correct?

henfri commented 2 years ago

I am in fact using Docker as well.

pyfisch commented 2 years ago

Ok, then something else causes different errors.

henfri commented 2 years ago

Well, for me it was the missing port - just like for you.