I use amavisd-new with my postfix installation for spam and virus detection, but I don't like the local mail forwarding entries that are generated in my mail headers.
So I set this option in my amavisd configution "$insert_received_line = 0;" that prevents the generation of one received entry when amavisd handles the forwarding. That works like a charm. But another entry is created if postfix process the message received from amavisd. See the localhost entry from my example mail. To prevent that, I tried the following:
- create a header_checks file with a regex that sets the Received entry with localhost to IGNORE
- include it into the "main.cf" with that statement: "header_checks = pcre:/etc/postfix/header_checks"
- and into the amavis filter configuration in the "master.cf" like that: 127.0.0.1:10025 inet n - - - - smtpd ... -o cleanup_service_name=headerclean ... headerclean unix n - n - 0 cleanup -o header_checks=pcre:/etc/postfix/header_checks
The header check rule works as aspected, I tried the expression with postmap. But unfortunately my localhost received entry ist still in the mail header. It appears that postfix doesn't not perform the headers check for the final mail delivery.
Thanks for your help.
Return-Path: <firstname.lastname@example.org> Delivered-To: email@example.com Received: from server.example.com (localhost [127.0.0.1]) by server.example.com (Postfix) with ESMTP id 731B71E0CE9 for <firstname.lastname@example.org>; Fri, 19 Oct 2012 14:31:57 +0200 (CEST) Received: from server.example.com (server.example.com [22.214.171.124]) by server.example.com (Postfix) with ESMTPSA id BE6E91E0CE8 for <email@example.com>; Fri, 19 Oct 2012 14:31:56 +0200 (CEST) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: Fri, 19 Oct 2012 14:31:56 +0200 From: Christian <firstname.lastname@example.org> To: <email@example.com> Subject: ... Message-ID: <firstname.lastname@example.org> Sample message body