Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Django, I want to insert a database record by sending myself an email?

I'm looking into a possible feature for my little to-do application... I like the idea that I can send an email to a particular email address, containing a to-do task I need to complete, and this will be read by my web application and be put in the database... So, when I come to log into my application, the to-do task I emailed will be there as a entry in the app.

Is this possible? I have a slice with SliceHost (basically a dedicated server) so I have total control on what to install etc. I'm using Python/Django/MySQL for this.

Any ideas on what steps to take to make this happen?

like image 630
littlejim84 Avatar asked Feb 27 '23 05:02

littlejim84


2 Answers

If I were to implement this, I'd use a scheduler and a job to be scheduled.

That job would connect to the mail server (be it POP3 or IMAP) and parse the unread messages (or messages unread by the job). Based on that I would insert that record.

You'd get 2 types of records that way. A list of mail message ids which have been processed (so you don't reprocess mails) and a list of tasks.

Disadvantage is that it takes some time before you see the task, as the job only executes every X minutes, or seconds.

If that is not good enough I'd go for a permanent IMAP connection, but you'd have to implement more error handling; you don't just retry automatically every X minutes.

Googling for Django +scheduler will get you started.

also have a look at this StackOverflow thread, no need to reinvent the wheel :)

like image 114
extraneon Avatar answered Mar 05 '23 17:03

extraneon


I needed the exact same thing. I use the Lamson project (which is written in python) to transform email, forward email based on rules to my www.evernote.com and thinking rock www.trgtd.com.au accounts, update firewall web filtering rules, update allow/deny lists for my spam filter, read and write databases etc....

I like to think of it as email server automation and email application development.

www.lamsonproject.org

Troy

like image 34
Troy Sorzano Avatar answered Mar 05 '23 18:03

Troy Sorzano