Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running a program upon receipt of an email

Status
Not open for further replies.

dugla

Programmer
Mar 19, 2003
3
IS
Hello,

I'm looking for a scalable way to run an external program upon receipt of an email sent to a particular address. I currently use an alias in /etc/aliasese and that works fine but I need an approach that can scale. I want some sort of snooper program that watches for mail arriving at a particular email address and then in a controlled way launches a program to service each email.

Thanks very much for the help.

Cheers,
Douglass Turner
 
you could write a program (in one of many languages) that periodically checks the mailbox(es) via POP3 and then does something when an email is retrieved.
 
I am not sure if i interpret your question right, because you mention that you already use '/etc/aliases'.
The standard way with sendmail is to use a line in '/etc/aliases' that looks like:

an_email_adress: "|/usr/local/bin/process_each_mail"

This way all emails sent to that adress are processed automatically. If this is what you already did, then try to 'rephrase' your question...
Good luck
 
nlhe,

I am indeed using an aliase similar to what you sketched. The problem with this approach is that if I get a spike in requests. Zillions of copies of the email processing executable get spawned quickly swamping my server. I need a way to sequences the calls in a controllable way.

-Doug
 
Asusming that since this is in the Sendmail forum you are running sendmail....

within your sendmail.cf file, create an entry such as follows (this example runs the program 'inflex' which is a virus
scanning front end for sendmail):

Minflex, P=/usr/local/inflex/inflex, F=ClsDFM:/|@qShPm,
S=0, R=0, T=DNS/RFC822/X-Unix,
A=inflex $h $u $f

The statement above routes all mail through inflex. You could create your own script that does what you'd like on the email (i.e. search for the email address that you are wanting to run a program on, if it matches, continue running the script which could call your external program, if it does not match, exit and the mail gets sent to its destination...)

Hope this helps,
Paul
 
Paul,

Doesn't this simply move the problem to a different place? How does your example address the problem of swamping the server with N copies of the same program cranking away at the same time?

-Doug
 
Why not stick with the aliases route and modify the script that you call adding a routeen that first checks how many of it's processes have spawned, and sleep untill that level drops to a acceptable threshold ?

Just a thought

L.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top