In general I agree with Jeff's suggestion. but OTOH you might be able to get pop to work and using the pop interface maybe you can get the headers in a clean pythonic fashion.
it sounds like you will also have to deal with attachments, so maybe the pop library can handle that nicely. the script way is this: In a hosted environment you often have the possibility to set up (using the host company's control panel) a recipe or similar that sends an email to a python shell script. the script then receives the whole raw email on STDIN standard in. If you control the server yourself, then you should be able to use postfix or whatever your email MTA is and again send the email to a shell script. so the recipe or command to execute is something like: /Library/Frameworks/Python.framework/Versions/Current/bin/python /full/path/to/yourhandler.py yourhandler.py can then get the entire body of the email (with all headers) via STDIN standard in. lines = sys.stdin.readlines() it then can use pattern matching to find the from address in the headers etc. there's probably some nice libraries that do this parsing already. alternatively you might be able to just dump the email to a file in a directory and later process the mails. or access the Maildir/new for that account directly. and then have a regular process that checks for new mails in the directory and processes them. either write a command that can be executed from manage.py (so you'll have the whole django stack and all of your apps avail to you) or import the settings and the most minimal amount of django that you'll need. or if you are really lazy, just write a view that processes the mails and set a cron to fetch the page every once in a while ( just wget or curl it ) -felix On Sun, Oct 26, 2008 at 8:13 PM, AndyB <[EMAIL PROTECTED]> wrote: > > This sounds like exactly what I need to do. However my Unix-fu isn't > up to coping with the sentence 'We have an alias set up in postfix > that sends the e-mail to our script via a pipe.'... :( > > My naive assumption is that one could use something like poplib in the > standard library to connect to a POP3 server and process incoming > emails that way. Does that sound a sensible route to take? > > Andy Baker > > On Oct 25, 7:09 pm, Jeff Anderson <[EMAIL PROTECTED]> wrote: > > umit wrote: > > > Hi, i am trying to build a quick blog system. But i want users can > > > send emails to submit messages with pictures. > > > How can i receive emails and process them? What should i use? > > > > We use Python's email module. > > > > We have an alias set up in postfix that sends the e-mail to our script > > via a pipe. > > > > The python script imports our Django models, and parses the e-mail > > message with the email module, and does what it needs to. > > > > This should give you a decent starting point. > > > > Cheers! > > > > Jeff Anderson > > > > signature.asc > > < 1KViewDownload > > > --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---