Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Catches OSError on IMAP connection error

syntonym5c1edf78cef2
diff --git a/src/documents/mail.py b/src/documents/mail.py
index afa1b4362..d54b387b7 100644
--- a/src/documents/mail.py
+++ b/src/documents/mail.py
@@ -216,7 +216,11 @@ class MailFetcher(Loggable):
return r
def _connect(self):
- self._connection = imaplib.IMAP4_SSL(self._host, self._port)
+ try:
+ self._connection = imaplib.IMAP4_SSL(self._host, self._port)
+ except OSError as e:
+ msg = "Problem connecting to {}: {}".format(self._host, e.strerror)
+ raise MailFetcherError(msg)
def _login(self):