1
0
Fork 1
mirror of https://github.com/coddingtonbear/django-mailbox.git synced 2026-07-09 22:38:19 +02:00
django-mailbox/django_mailbox/management/commands/getmail.py
me@adamcoddington.net 0515cf7f74 Do not attempt to fetch mail for mailbox not having a URI.
--HG--
branch : exim4_pipe
2012-10-08 15:28:37 +00:00

19 lines
710 B
Python

from django.core.management.base import BaseCommand
from django_mailbox.models import Mailbox
class Command(BaseCommand):
def handle(self, *args, **options):
mailboxes = Mailbox.objects.all()
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:
self.stdout.write('Recieved %s (from %s)\n' % (
message.subject,
message.from_address
))