def handle(self, *args, **options): log.info("checking for new emails") gmail = poplib.POP3_SSL(settings.POP_SERVER, settings.POP_PORT) gmail.user(settings.POP_USER) gmail.pass_(settings.POP_PASSWORD) num_messages = len(gmail.list()[1]) for i in range(num_messages): email_txt = '\n'.join(gmail.retr(i+1)[1]) gmail.dele(i+1) msg = email.message_from_string(email_txt) j = email_to_job(msg) if j: log.info("found a new job email: %s", j) gmail.quit()
def handle(self, *args, **options): log.info("checking for new emails") gmail = poplib.POP3_SSL(settings.EMAIL_HOST, settings.EMAIL_POP_PORT) gmail.user(settings.EMAIL_HOST_USER) gmail.pass_(settings.EMAIL_HOST_PASSWORD) num_messages = len(gmail.list()[1]) for i in range(num_messages): email_txt = '\n'.join(gmail.retr(i+1)[1]) gmail.dele(i+1) msg = email.message_from_string(email_txt) j = email_to_job(msg) if j: log.info("found a new job email: %s", j) gmail.quit()
def handle(self, *args, **options): for mbox in mboxes(): for msg in mailbox.mbox(mbox): job = email_to_job(msg) if job: log.info("loaded %s", job)