Problem with mail

what I have to write in a shell that every time that it arrives a new
e-mail has to perform a program taking some data from the e-mail.

This can be done in many ways without writing a program because the programs to receive mail and call actions based on mail receipt exist. Examples include:

(1) The <B>.forward</B> file for users can be used to call programs when mail arrives.

(2) Mail handleing programs such as <B>procmail</B> can perform very sophisticated mail filtering and triggering actions.

(3) <B>sendmail</B> and other mail deamons can be modified to do as you desire. Other mailers have builtins as well.

I recommend either (1) or (2) for the beginner. (1) is the easiest. Normally, helps to start simple and small and move to more complex as your knowledge base increases.

In a nutshell, you don't have to write a program to manange and trigger on mail, that is done; you can install, configure and concentrate on your end user task based on the trigger or message.

here we actually have it set up in sendmail.cf that if "x" user gets mail it is rerouted to an external script that breaks down the email and does some stuff to it then repackages it and dumps the file to disk and ftped out to another machine.