Automated Email

Hey all,

I’ve tried to google arroud on the internet for an answer to this one, but I haven’t seemed to find an answer.

Here’s what I’m looking to do. (FYI… this is a *nix system).

I’d like to have a script run whenever an email to a certian address is receaved. My getto solution right now is to have a cron tab set up to run a script to check for new emails every few minutes. However, if there is a way possible, I’d much rather have the script only run when an email arrives as opposed to running it every few minutes.

I’m not exactly sure of the mail server specs, but if that’s important, I can get them.

I’d figure something like this has to be possible, after all auto-responders are sent whenever new mail is receaved, but in my case I don’t want to send an email back, I want to execute a script of mine.

Thanks,

Jack

You might want to look at procmail. It’s pretty common on unix systems. I’ve never messed with it but it looks like it’ll do what you want. There’s pretty good documentation in the man page and the FAQ’s on procmail’s site (procmail.org) have some very basic examples.

The way it’s done for the mailman software is like this (in my case its in /etc/aliases, but that can vary depending on system setup):

test: “|/usr/lib/mailman/mail/mailman post test”
(with other aliases setup in a similar way passing different paramaters to the mailman binary).

I thought of recommending that method, but it depends on whether the message also needs to be delivered to the mailbox, besides running the script.

If you only need to run a script when the e-mail is sent, the mailman method will work. If the e-mail needs to be delivered and also the script run, procmail is probably your best bet.

You really can only do that if you can run a program that checks, so you would need to ask your server to run a program, or run a program on a computer that you control, but make sure its always on.