How do I remove Received-headers from emails?

I'm using Postfix 2.3.3 and mail sent from my server always add useless headers which I'd like to remove. Currently I'm only using the PHP mail() function to send mail.

Return-Path: 
Received: from mss-us4.mail.pw (localhost.localdomain [127.0.0.1])
 by mss-us4.mail.pw (Postfix) with ESMTP id EBAF41540011
 for ; Mon,  7 Dec 2009 16:59:02 +0000 (GMT)
Received: from mx2.mail.pw (inbound-us2.mail.pw [70.87.x.x])
 by mss-us4.mail.pw (Postfix) with ESMTP
 for ; Mon,  7 Dec 2009 16:59:02 +0000 (GMT)
Received: from mail.domain.org (unknown [x.172.x.x])
 by mx2.mail.pw (Postfix) with ESMTP id 6B20F56063B
 for ; Mon,  7 Dec 2009 16:59:02 +0000 (GMT)
Received: from ip1.domain.org (ip1.domain.org [127.0.0.1])
 by mail.domain.org (Postfix) with ESMTP id 1E5B018080AC
 for ; Mon,  7 Dec 2009 11:59:02 -0500 (EST)
Received: (from apache@localhost)
 by ip1.domain.org (8.13.8/8.13.8/Submit) id nB7Gx2lR016074;
 Mon, 7 Dec 2009 11:59:02 -0500

I've compared mine to Gmail headers and from what I've seen are the last two useless headers. Also how do I change the return path from within the Postfix configuration?


Solution 1:

FWIW, this is a bad idea for Received headers but here's the answer anyways. womble mentioned content_filter as a recommended solution. IMHO that's overkill, Postfix supports this natively via header_checks.

/etc/postfix/main.cf:

header_checks = regexp:/etc/postfix/header_checks

/etc/postfix/header_checks:

/^Received:.*\[127\.0\.0\.1\]/         IGNORE
/^Received:.*\from apache@localhost/   IGNORE

Solution 2:

Every header is useless -- until the day you really actually need that information to diagnose some irritating problem.

If you're dead-set on doing this, then you want to look at the content_filter parameter.