#!/home/alfredo/mysite_env/bin/python import sys, os import imaplib from django.contrib.auth.models import User
popserver = 'pop.gmail.com' user = 'u...@gmail.com' password = '-------' def CheckEmail(email): try: p = User.objects.get(email = email) if p.email == email: if p.is_active == 1: checkemail = 1 elif p.is_active == 0: checkemail = 2 except User.DoesNotExist: checkemail = 0 return checkemail ########## mail = imaplib.IMAP4_SSL('imap.gmail.com') mail.login(user, password) mail.select("inbox") typ, mess_email = mail.search(None, 'ALL') for num in mess_email[0].split(): r, data = mail.fetch(num, '(UID BODY[TEXT])') body_text = data[0][1].strip().lower().split() r, data = mail.fetch(num, '(UID BODY[HEADER.FIELDS (FROM)])') body_from = data[0][1].lstrip('From: ').strip().lower().split()[-1].replace('<','').replace('>','') CheckEmail(body_from) print body_from print body_text mail.close() mail.logout() 2011/11/10 nicolas HERSOG <n.her...@gmail.com>: > Can you show us your script and how you launch it ? > > On Wed, Nov 9, 2011 at 9:27 PM, Alfredo Alessandrini <alfreal...@gmail.com> > wrote: >> >> Hi, >> >> I'm running a script to make a query with django. >> >> I need to run it in crontab. >> >> When I run it I get this error: >> >> ImportError: No module named profiles >> >> I'm using a virtualenv. >> >> >> Thanks, >> >> Alfredo >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-users@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.