In exim, I create a transport that uses a pipe to send the email to my
shell script.  I also create a router that sends every mail that exim
processes to my transport (providing I haven't already processed it).

My shell script reads the email from stdin and parses it based on some
custom rules.

If it passes the rule checks it can be sent back into exim.  This is
achieved by writing to the stdin of the exim command with some
additional parameters.  Once I've given the email back to exim, I want
to check for data on it's (exim command) stdout and stderr so that I
can log any problems.

The interaction with exim is straight from the exim book and all works
ok.  The question I have is really about the best way to deal with
piping data to/from different processes within ruby in addition to
trying to understand what's going on better.

I did use IO.popen to start with and can't now remember the problems I
had, probably just ignorance on my part..

Chris