WebFaction
Community site: login faq
0
1

I'm wondering whether it's possible to execute an action in python on receipt of email. This python script can then send a custom automated reply, and make updates to the database as required. Specifically, I would like to allow reply-by-email on my website.

Even if I could set up a cron to look for new email every few minutes, how would I read the mail? Is that possible?

asked 23 Mar '11, 04:58

Herman
72712
accept rate: 0%


We actually have a system set up to do almost exactly what you want: mail2script. This lets you send mail directly to a script for parsing.

Of course, you could also just use an IMAP library to manually connect to the mailserver and fetch your messages.

permanent link

answered 23 Mar '11, 05:11

David L ♦♦
1.4k13
accept rate: 45%

Wow, fantastic - thanks!

(23 Mar '11, 05:18) Herman

Yup! Python can do pretty much anything :-)

What you'll probably want to do is poll your mail server via cron with imaplib. There's a pretty lengthy howto to get you started here:

http://www.doughellmann.com/PyMOTW/imaplib/
permanent link

answered 23 Mar '11, 05:10

danielquinn
1211310
accept rate: 14%

edited 23 Mar '11, 05:11

Webfaction has email2script which you can use to capture email everytime you receive one. Here is the link to webfaction script, http://docs.webfaction.com/user-guide/email.html

You can example output the emails to file or create a own script that will handle the emails received, eg. parse it, store it to database etc.

permanent link

answered 23 Mar '11, 05:19

tiparkki
2138
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×337
×261
×81

question asked: 23 Mar '11, 04:58

question was seen: 8,679 times

last updated: 23 Mar '11, 05:19

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM