Sunday, February 26, 2012

SENDING TO EVERYONE. PASS IT ON.

I think I need to create a script that

1. Scans my gmail inbox for any mail whose subject line uses ALL CAPS and which urges me to forward it to everyone I know;
2. Searches snopes.com for the message body;
3. Replies with a link to the top Snopes hit and its text, plus a preachy little sermon by me on the importance of Truth

... all automatically.

What sort of tools can I use to make such a script?

If you don't know, please forward my question on to everyone you know. It's very important. It probably involves President Obama and/or dead babies.

4 comments:

jafo said...

Well... Gmail supports IMAP access...

So something like:

server = imaplib.IMAP4('gmail.com')
server.login(login, passwd)
server.select('INBOX')
typ, data = server.uid('search', 'ALL')

for uid in data[0].split():
  typ, fetch = server.uid('fetch', uid, '(RFC822)')
  body = fetch[0][1]
  msg = email.message_from_string(body)
  print 'Subject:', msg.get('Subject')

That's a start, then you just need to send the message.

Does that help any?

Sean

Catherine said...

Thanks, Sean! When I can get to it in a couple weeks, I'll list you as a co-author on LetMeSnopesThatForYou.

Craig Maloney said...

I desperately need this for all of the stuff that my mom sends my way. Anything that has "Fw: " in the subject should head to snopes for a simple check.

Even running the first sentence through Google should be enough.

This is one of my pet projects, so if you decide to create a public repo for it, LMK.

James said...

Excellent problem reduction. Now if I could only get Aunt Gertie to do it...:-)