2012-06-27 20:45:01 -07:00
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
|
|
|
|
|
|
from django_mailbox.models import Mailbox
|
|
|
|
|
|
|
|
|
|
class Command(BaseCommand):
|
|
|
|
|
def handle(self, *args, **options):
|
2012-10-09 05:52:04 +00:00
|
|
|
mailboxes = Mailbox.active_mailboxes.all()
|
2012-06-27 20:45:01 -07:00
|
|
|
if args:
|
|
|
|
|
mailboxes = mailboxes.filter(name = ' '.join(args))
|
|
|
|
|
for mailbox in mailboxes:
|
|
|
|
|
self.stdout.write('Gathering messages for %s\n' % mailbox.name)
|
2012-06-28 09:41:31 -07:00
|
|
|
messages = mailbox.get_new_mail()
|
|
|
|
|
for message in messages:
|
2013-01-15 15:48:15 +00:00
|
|
|
self.stdout.write('Received %s (from %s)\n' % (
|
2012-06-28 09:41:31 -07:00
|
|
|
message.subject,
|
|
|
|
|
message.from_address
|
|
|
|
|
))
|