tags:

views:

89

answers:

3

After hearing about git commit hooks, I was thinking maybe there are such things as email hooks...

Is it possible for me to build a program that says "hey, you just received an email, now run this ruby script"? Something like a GMail Web Hook. Is there anything out there like that? I mean I could build a cron thing that checked my email all the time, but maybe there's a more formal way.

Looking for an online email system to do this with, not say my Mac Mail.

+1  A: 

The answer to this depends entirely on how you read your email. There are no user-accessible hooks in gmail, AFAIK, but you can pull gmail via POP3 and suck it through some mail processing system such as procmail.

Marcelo Cantos
+3  A: 

You can try smtp2web. It basically consists of a SMTP daemon that maps incoming email to HTTP urls. Then, you can run the server-side code of your choice on those URLs. This is just one way to approach the problem. It's designed particularly for use with Google App Engine.

You can either run your own instance, or just sign up for mapping (e.g. [email protected] -> http://viatropos.com) and forward your gmail account to that. Then, you would run a HTTP server at viatropos.com.

EDIT: I also found Astrotrain, which is similar but written in Ruby.

Matthew Flaschen
that looks awesome, but kind of sketchy due to it's very minimalistic nature :)
viatropos
op, but it was [built by a google guy](http://almaer.com/blog/smtp2webcom-bridge-smtp-to-http-let-app-engine-accept-email), great!
viatropos
+1  A: 

You can forward all incoming emails to a script. Normally a .forward file in your home directory that looks similar to this would be enough:

|/path/to/your/script

The script has to be executable.

Here's an article about it. It's for PHP but it's the same for ruby. In the script you just need to read the STDIN to get the message.

Tomas Markauskas