Solved

Run a program whenever new mail is received

Posted on 1997-08-25
13
372 Views
Last Modified: 2010-04-22
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?
0
Comment
Question by:Slarti
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 2
  • +1
13 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 2006702
1'st create following entry in /etc/aliases:
zvikabh: "|gigo.out"
2'nd restart sendmail
0
 
LVL 2

Author Comment

by:Slarti
ID: 2006703
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.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 2006704
>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

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 2

Author Comment

by:Slarti
ID: 2006705
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.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 2006706
> 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).
0
 
LVL 2

Author Comment

by:Slarti
ID: 2006707
>> 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...

0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 2006708
Have you tried a .forward like:

"|gigo.out"

0
 
LVL 2

Expert Comment

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

0
 
LVL 2

Author Comment

by:Slarti
ID: 2006710
I tried ahoffman's suggestion and got the same result (service unavailable).
0
 
LVL 2

Author Comment

by:Slarti
ID: 2006711
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.
0
 
LVL 84

Expert Comment

by:ozo
ID: 2006712
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)

0
 
LVL 2

Accepted Solution

by:
df020797 earned 50 total points
ID: 2006713
If you ar enot root, then use .forward to pipe the mails incoming to a program. If you only have account and also want ot be able to receive "normal" mail and pass on certain mails to a program, then use .forward to send all incoming mail to procmail, a mail filtering program, that will be able to tell what it should do with different mail from a rulest you write and put in .procmailrc locally on your accnt... i.e. no root interference
0
 
LVL 2

Author Comment

by:Slarti
ID: 2006714
Thank you for your answer, it was just what I needed.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question