mirror of
https://github.com/coddingtonbear/django-mailbox.git
synced 2026-07-09 22:38:19 +02:00
Return None for connection if no URI is specified in mailbox settings.
--HG-- branch : exim4_pipe
This commit is contained in:
parent
0515cf7f74
commit
ffbf4ace6b
2 changed files with 6 additions and 4 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue