1

I want to process a particular mailbox when it receives mail, I know I could have cron check every n minutes for any mail, but wondering if there's a way to "listen" for mail rather than continually polling.

Ronn
  • 1,753
  • 4
  • 28
  • 38

5 Answers5

3

Try a .forward file

You can pipe the message into any program or script you want, but also check if procmail can do what you want.

finnw
  • 47,861
  • 24
  • 143
  • 221
3

If you're using postfix I'd suggest aliasing the mailbox you're interested in to a process that will do the work for you. Then there's no polling. The message comes in and goes directly to being processed.

Community
  • 1
  • 1
Restore the Data Dumps
  • 38,967
  • 12
  • 96
  • 122
3

Depending on your mail server, it may be possible to actually have any incoming message be delivered to a process. Either in a .forward or by setting up something more advanced. In exim you can setup a transport to run a command, for certain addresses.

Zoredache
  • 37,543
  • 7
  • 45
  • 61
2

As Jason and Zoredache have already mentioned, you might be able to do this in the MTA itself. Another possibility is to have inotify watch the mailbox file or maildir.

Community
  • 1
  • 1
Paul Tomblin
  • 179,021
  • 58
  • 319
  • 408
2

if you dont have a mail-server on your own (root-access) - you could use a web service for that: http://cloudmailin.net (200mails/month for free) - works like charme and helped me out.

Daniel Schönherr
  • 235
  • 1
  • 3
  • 12