Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fire an event when email is received

Tags:

email

imap

I'm trying to write something that puts the contents of the message on a queue, to have work done on it later. I've been messing around with IMAP IDLE with varying degrees of success.

I was wondering if anyone knows of a method to have a mail server receive an email, and then perform an action like posting the contents of the email to a URL endpoint.

Any ideas? Thanks!

like image 605
Benny Wong Avatar asked Nov 22 '08 17:11

Benny Wong


1 Answers

Try fetchmail and procmail. You periodically poll the mail server (every minute if necessary) and use fetchmail to download from the IMAP server. Set up a procmail rule to run your notifier application on emails that match your selection criteria.

Any of the scripting languages (perl, python, tcl/tk etc.) have good, mature and easy to use email handler libraries (in fact you can get this sort of thing for most lanaguages), so it should be quite straightforward to write the handler in one of those.

like image 70
ConcernedOfTunbridgeWells Avatar answered Nov 07 '22 14:11

ConcernedOfTunbridgeWells