def handle_noargs(self, **options): from djpostman.models import EmailBox, Message, Contact from djpostman.receiver import ImapMailReceiver try: mr = ImapMailReceiver() print "IMAP Sync: %s" % mr.get_connection() mr.connect() count = mr.fetch_mail() mr.disconnect() print "%s mails fetched" % count except Exception, e: print "ERROR: %s" % str(e)