tags:

views:

136

answers:

5

If my email id receives an email from a particular sender, can I ask sendmail to trigger a different program and pass on the newly arrived email to it for further processing? This is similar to filters in gmail. Wait for some email to arrive, see if it matches the criteria and take some action if it does.

A: 

We handle this by having a cron process running on the mail server which watches the inbox directory and scans any new messages (files) every 10 minutes or so.

When the process finds an email of interest, it fires the information off to another process which then reacts to the new message (and, in our case, removes the message from the inbox).

--edit--

Finding the email inbox depends on your implementation - check the 'manual' your version of sendmail for details - we direct incoming email to a special directory or have parameters to work out the inbox details. I don't feel it would be useful to be more specific as the answer to 'where is the inbox' is 'it depends'.

As for the pattern to search for - we decode the email message (a text file) into a DOM that we can manipulate. For example, we can then look for specific words in property 'subject'.

ColinYounger
Do you mind elaborating on this a little? Where do I find the inbox folder and what's the pattern I should search for while looking for a recipient? Some snippets would be really helpful. Thanks much.
Subbu
A: 

are you talking about email clients? If so then you can set rules in outlook and I am sure there mustbe ways in other email cleints too!! If u are asking something else. sorry

Shoban
+2  A: 

This is what Procmail is for.

Set Sendmail up to use procmail as the mail delivery agent (MDA), or set up your .forward to pipe stuff through procmail. (See the man page.)

Then you can write your .procmailrc to do all sorts of things along these lines.

This filter predates gmail. Still useful if you're running a mail server.

JBB
This is *exactly* what procmail is for. Don't even *think* about using cron.
bmb
A: 

@shoban: No I am not talking about email clients.

Subbu
A: 

ok. then I suggest Colins method.. I use cron to monitor emails (for a particluar domain) and send text messages as alerts!. Similar to what you are asking!

Shoban