Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

For incoming emails to a postfix server, i would like to record the timestamp in the "Receive: from" header.

For example, from an email containing:

Received: from mailserver01 ([192.168.0.25]) by mailserver01.domain.intra with Microsoft SMTPSVC(6.5);
 Mon, 16 Jul 2012 17:09:36 +0200

I would like to extract:

Mon, 16 Jul 2012 17:09:36 +0200

What i would like to know is how to configure postfix to log that information (just the timezone or the whole "Received: from" header). I can handle the parsing to extract the information once i have that line logged.

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

I'm not aware of any config option to customize the log format. Have you tried running postconf to see if there's any option that deals with the log format?

Anyway, a similar question has been asked before, and it seems that it's not possible

Postfix custom log

share|improve this answer
add comment

You can pass it to cut

echo "Received: from mailserver01 ([192.168.0.25]) by mailserver01.domain.intra with Microsoft SMTPSVC(6.5);      Mon, 16 Jul 2012 17:09:36 +0200" | cut -d ";" -f 2

or if you place email content in bash variable:

cat $email | grep "Received:" | cut -d ";" -f 2
share|improve this answer
    
I dont need to do the parsing, what i need to do is the logging. But thanks anyway! –  elhoim Jul 25 '12 at 8:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.