Solved

Run a program whenever new mail is received

Posted on 1997-08-25
13
336 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
  • 6
  • 4
  • 2
  • +1
13 Comments
 
LVL 51

Expert Comment

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

Author Comment

by:Slarti
Comment Utility
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
Comment Utility
>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
 
LVL 2

Author Comment

by:Slarti
Comment Utility
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
Comment Utility
> 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
Comment Utility
>> 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
Have you tried a .forward like:

"|gigo.out"

0
 
LVL 2

Expert Comment

by:df020797
Comment Utility
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
Comment Utility
I tried ahoffman's suggestion and got the same result (service unavailable).
0
 
LVL 2

Author Comment

by:Slarti
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thank you for your answer, it was just what I needed.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
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 how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now