forked from mirror/django-mailbox
Initial commit.
This commit is contained in:
commit
413b60e35f
13 changed files with 340 additions and 0 deletions
0
django_mailbox/management/commands/__init__.py
Normal file
0
django_mailbox/management/commands/__init__.py
Normal file
18
django_mailbox/management/commands/getmail.py
Normal file
18
django_mailbox/management/commands/getmail.py
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
from django.core.management.base import BaseCommand
|
||||
from django.dispatch import receiver
|
||||
|
||||
from django_mailbox.models import Mailbox
|
||||
from django_mailbox.signals import message_received
|
||||
|
||||
class Command(BaseCommand):
|
||||
def handle(self, *args, **options):
|
||||
mailboxes = Mailbox.objects.all()
|
||||
if args:
|
||||
mailboxes = mailboxes.filter(name = ' '.join(args))
|
||||
for mailbox in mailboxes:
|
||||
self.stdout.write('Gathering messages for %s\n' % mailbox.name)
|
||||
mailbox.get_new_mail()
|
||||
|
||||
@receiver(message_received)
|
||||
def incoming_message(self, sender, message, **kwargs):
|
||||
self.stdout.write('Received %s\n' % message.subject)
|
||||
Loading…
Add table
Add a link
Reference in a new issue