How to send message headers of new emails to another email address using Postfix?

I'm using Fedora Core 4 and Postfix as my mail server on a small domain I operate.

I would like to get the message headers from my mailbox sent to an email address of my choice... preferrably my cell phone.
I've been tinkering with aliases and .forward files to try and accomplish this, but haven't had much luck yet.

Has anyone here successfully done something like this?
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.

Gabriel OrozcoSolution ArchitectCommented:
I have done some scripting using formmail

and also some bash scripting...

I think you can put a script in your local .forward in order to local deliver while also send a copy to your script.
scorbinAuthor Commented:
I'm not entirely familiar with formmail, but am quite a bit more familiar with bash.  I'm not sure if this is the approach I want to take quite yet.  Of course, I'll result to brute force if need be, but my naiveity still thinks there may be a more innovative way to approach my problem.

Have you got any other ideas?
Gabriel OrozcoSolution ArchitectCommented:
there are some problems

you need to write a parser to fully separate the headers. I think an approach could be to look for the first blank line and all previous lines are headers.
if you can separate the headers to a temporary file,  it's a question only to mail such file to your defined email account.
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

scorbinAuthor Commented:
The header shouldn't be too awefully bad to parse, I can always parse the source and retrieve the sender and subject.

Maybe I should restate my main concerns.  I wasn't able to successfully figure a way to modify the aliases or .forward file to "mirror" messages to another email address.  I don't want to simply forward the messages, but instead detect when a new messsage arrives and then run a small script that parses the message and sends what I want from it.

I can do the script, that's not really the problem.  It's finding a method to handle an event of a new mail message.

Hopefully I haven't been overly ambiguous with my description.  If so let me know.
Gabriel OrozcoSolution ArchitectCommented:
I Understand better now

well, if you are using sendmail, you can do this in the .forward file (The same I suppose you use to mirror messages) like in here:

all this can be reduced to

youruser, |/usr/local/scripts/
where your script has the email as it's input.

but I would consider procmail as the better tool for the job if you want to do things with each email received:

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
scorbinAuthor Commented:

You're on top of it.  That's the page/info I was looking for.

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
Linux Networking

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.