Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2006-04-10
6
Medium Priority
?
260 Views
Last Modified: 2011-09-20
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?
0
Comment
Question by:scorbin
  • 3
  • 3
6 Comments
 
LVL 19

Expert Comment

by:Gabriel Orozco
ID: 16423492
I have done some scripting using formmail
http://www.scriptarchive.com/readme/formmail.html

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.
0
 

Author Comment

by:scorbin
ID: 16423770
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?
0
 
LVL 19

Expert Comment

by:Gabriel Orozco
ID: 16423858
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.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:scorbin
ID: 16428097
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.
0
 
LVL 19

Accepted Solution

by:
Gabriel Orozco earned 1000 total points
ID: 16428756
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:
http://www.itworld.com/AppDev/4061/UIR010411regex2/

all this can be reduced to

.forward:
youruser, |/usr/local/scripts/myemailscript.sh
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:
http://www.procmail.org/
0
 

Author Comment

by:scorbin
ID: 16431378
Redimido...

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

THANKS!
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Suggested Courses

581 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