How to extract header data from emails and trigger server scripts.

Hello Experts

I want to extract some header information from emails sent to my server and have them trigger a script that can use the information from the email. I don't want to use email forwarding, which is the simplest solution of course.

So this is what I would like to happen

1. email sent to to:  from: (or wherever)

2. extract user1 and add it to the forwarding address using a script triggered by the incoming email, ie the script sends an email to  and includes the message body and it appears to come from not the user's original sending address (ie gmail, hotmail, isp etc)

This is because my service provider sometimes sends computer generated non-delivery emails back to my users, and I don't want them to know who my service provider is (otherwise they may not use my service!!). If delivery is successful my provider does not send a reply. Similiariliy when my service provider emails back I would like a script to extract the message body and send it to the user.

I think I need to use sendmail and some perl (or other) scripting for this?

Also I rent the server from a hosting company. It's not dedicated to me, it just allocates certain bandwidth and diskspace to me according to how much I want to pay. I have cgi-bin, but I'm waiting for them to inform whether or not it has sendmail or if I can install it.

This is my first question here, so I hope I'm using the right language and making sense. Please help. Thanks
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


this is not a web server functionality.  Sounds to me like all you need is to run your own mail server - yes, sendmail, postfix or some other mail system software.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.