From ffbf4ace6b638085de260003eddddd28e89e32b2 Mon Sep 17 00:00:00 2001 From: "me@adamcoddington.net" Date: Mon, 8 Oct 2012 15:30:32 +0000 Subject: [PATCH] Return None for connection if no URI is specified in mailbox settings. --HG-- branch : exim4_pipe --- django_mailbox/management/commands/getmail.py | 2 -- django_mailbox/models.py | 8 ++++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/django_mailbox/management/commands/getmail.py b/django_mailbox/management/commands/getmail.py index e74f683..5f1aad3 100644 --- a/django_mailbox/management/commands/getmail.py +++ b/django_mailbox/management/commands/getmail.py @@ -8,8 +8,6 @@ class Command(BaseCommand): if args: mailboxes = mailboxes.filter(name = ' '.join(args)) for mailbox in mailboxes: - if not mailbox.uri: - continue self.stdout.write('Gathering messages for %s\n' % mailbox.name) messages = mailbox.get_new_mail() for message in messages: diff --git a/django_mailbox/models.py b/django_mailbox/models.py index 5e91395..41be837 100755 --- a/django_mailbox/models.py +++ b/django_mailbox/models.py @@ -64,7 +64,9 @@ class Mailbox(models.Model): return '+ssl' in self._protocol_info.scheme.lower() def get_connection(self): - if self.type == 'imap': + if not self.uri: + return None + elif self.type == 'imap': conn = ImapTransport( self.location, port=self.port if self.port else None, @@ -102,8 +104,10 @@ class Mailbox(models.Model): return msg def get_new_mail(self): - connection = self.get_connection() new_mail = [] + connection = self.get_connection() + if not connection: + return new_mail for message in connection.get_message(): msg = self.process_incoming_message(message) new_mail.append(msg)