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)