Merge pull request #228 from ddddavidmartin/extend_email_handling

Set email inbox in config file, fetch email at consumer startup and bring documentation up to date
This commit is contained in:
Daniel Quinn
2017-05-27 13:07:17 +01:00
committed by GitHub
5 changed files with 23 additions and 10 deletions

View File

@@ -219,7 +219,7 @@ class MailFetcher(Loggable):
if not login[0] == "OK":
raise MailFetcherError("Can't log into mail: {}".format(login[1]))
inbox = self._connection.select("INBOX")
inbox = self._connection.select(self._inbox)
if not inbox[0] == "OK":
raise MailFetcherError("Can't find the inbox: {}".format(inbox[1]))

View File

@@ -28,6 +28,7 @@ class Command(BaseCommand):
self.file_consumer = None
self.mail_fetcher = None
self.first_iteration = True
BaseCommand.__init__(self, *args, **kwargs)
@@ -66,6 +67,9 @@ class Command(BaseCommand):
self.file_consumer.consume()
# Occasionally fetch mail and store it to be consumed on the next loop
# We fetch email when we first start up so that it is not necessary to
# wait for 10 minutes after making changes to the config file.
delta = self.mail_fetcher.last_checked + self.MAIL_DELTA
if delta < datetime.datetime.now():
if self.first_iteration or delta < datetime.datetime.now():
self.first_iteration = False
self.mail_fetcher.pull()

View File

@@ -244,8 +244,10 @@ MAIL_CONSUMPTION = {
"PORT": os.getenv("PAPERLESS_CONSUME_MAIL_PORT"),
"USERNAME": os.getenv("PAPERLESS_CONSUME_MAIL_USER"),
"PASSWORD": os.getenv("PAPERLESS_CONSUME_MAIL_PASS"),
"USE_SSL": os.getenv("PAPERLESS_CONSUME_MAIL_USE_SSL", "y").lower() == "y", # If True, use SSL/TLS to connect
"INBOX": "INBOX" # The name of the inbox on the server
# If True, use SSL/TLS to connect
"USE_SSL": os.getenv("PAPERLESS_CONSUME_MAIL_USE_SSL", "y").lower() == "y",
# The name of the inbox on the server
"INBOX": os.getenv("PAPERLESS_CONSUME_MAIL_INBOX", "INBOX")
}
# This is used to encrypt the original documents and decrypt them later when