Link to home
Start Free TrialLog in
Avatar of Slarti
Slarti

asked on

Run a program whenever new mail is received

I am working on a program to filter out spam. I'd like the program to be run whenever new mail is received in my public e-mail box, and if it is acceptable, the program forwards it to a private e-mail box. I changed my .forward file to the following:
\zvikabh,"|gigo.out"
(the zvikabh is to keep a copy of the e-mail in the public e-mail box, and gigo.out is the filtering program.)
When I receive mail, I get a "returned mail: service unavailable" error e-mail from the mailer. The message contains the following lines:

sh: gigo.out not available for sendmail programs
554 "| gigo.out"... Service unavailable

and gigo.out is not run. Why is this happening?
Avatar of ahoffmann
ahoffmann
Flag of Germany image

1'st create following entry in /etc/aliases:
zvikabh: "|gigo.out"
2'nd restart sendmail
Avatar of Slarti
Slarti

ASKER

I can't accept your answer, because I can't write to /etc/aliases in my system - it's set so that only the sysadmin can modify it. I am looking for a way to do this that will not require any sysadmin priviledges.
>I can't write to /etc/aliases
I'm somewhat confused. How then can your
      "program forwards it to a private e-mail box" ?
If this is possible you may also add what I suggested to your private account.

An other solution would be to call gigo.out peridically by cron.
It then must read your mail database ($MAIL), like:
  mv $MAIL $MAIL.check
  your_filter $MAIL.check >checked
  cat checked >>$MAIL

Avatar of Slarti

ASKER

I forward mail to another account by editing the .forward file in my home directory. For instance, if it contains the line
target@address.com
then all my mail is forwarded to that address.

I cannot accept the crontab suggestion. First of all, it is not the correct approach; I don't have to continuously monitor my mailbox, since it should be possible for the computer to run a job whenever new mail is received. Second, the computer I am using has limitations on the frequency in which users can run crontabs, and I would like high frequency checks.

I am told that this can be done in a fashion similar to the /etc/aliases suggestion, but without sysadmin priviledges.
> I am told that this can be done in a fashion similar to the /etc/aliases suggestion, but without sysadmin priviledges.

Could you please be more specific?
AFAIK, the only solution with sendmail is the one suggested in my 1'st answer.
It's also possible tou use includes in /etc/aliases, but I think that each included file may only contain real user and/or group names, but no programs (I've never tested with programs there).
Avatar of Slarti

ASKER

>> I am told that this can be done in a fashion similar to the /etc/aliases suggestion, but without sysadmin priviledges.

> Could you please be more specific?

Someone once told me how to do it, but I forgot...

Have you tried a .forward like:

"|gigo.out"

If you are root, in the /etc/aliases: alias: "| the-program you want to run". This also works in your .forward file...

Avatar of Slarti

ASKER

I tried ahoffman's suggestion and got the same result (service unavailable).
Avatar of Slarti

ASKER

df: as I said in the comments above, I am not root and would like to solve this problem without contacting the root of my computer. Besides, ahoffmann already suggested exactly the same answer and I rejected it.
Avatar of ozo
Is gigo.out executable, and in sendmail's path?
Have you tried
chomd a+x gigo.out
and
|/usr/people/zvikabh/gigo.out

(or whatever the full path to the file is)

ASKER CERTIFIED SOLUTION
Avatar of df020797
df020797

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Slarti

ASKER

Thank you for your answer, it was just what I needed.