1 (edited by Mef 2015-02-21 20:54:55)

Topic: Clean up header

======== Required information ====
- iRedMail version: 0.8.7
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MySQL
- Linux/BSD distribution name and version: Ubuntu 14.04 LTS
- Related log if you're reporting an issue:
====
Recently I've set my iredmail server as primary MX. While test period (as secondary mx) I checked it on http://mxtoolbox.com/ and http://mail-tester.com services - everything gonna be ok.

But as my server become primary it has been got to DNSBL by Spamhaus ZEN. The reason on its site was bad HELO - localhost [127.0.0.1], but all test show it is right fqdn - mail.mydomain.com.

For investigation I've looked into header of my email, here it is (for short view only 'received' fields):
Header of the eml sent with roundcube:

Received: by 10.27.178.10 with SMTP id b10csp267363wlf;
        Wed, 18 Feb 2015 22:52:49 -0800 (PST)
Received: from mail.mydomain.com (mail.mydomain.com. [xxx.xxx.xxx.xxx])
        by mx.google.com with ESMTPS id z2si4177050lal.19.2015.02.18.22.52.47
        for <xxxxx@gmail.com>
        (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 18 Feb 2015 22:52:47 -0800 (PST)
Received: from localhost (localhost [127.0.0.1])
    by mail.mydomain.com (Postfix) with ESMTP id 6E4D2814A5
    for <xxxxx@gmail.com>; Thu, 19 Feb 2015 09:52:22 +0300 (MSK)
Received: from mail.mydomain.com ([127.0.0.1])
    by mail.mydomain.com (localhost [127.0.0.1]) (amavisd-new, port 10024)
    with ESMTP id F-WRYjAfrm40 for <xxxxx@gmail.com>;
    Thu, 19 Feb 2015 09:52:22 +0300 (MSK)
Received: from mail.mydomain.com (localhost [127.0.0.1])
    by mail.mydomain.com (Postfix) with ESMTPSA id F0D7381461
    for <xxxxx@gmail.com>; Thu, 19 Feb 2015 09:52:20 +0300 (MSK)

For Thunderbird client last 'Recieved' looks like below:

Received: from [192.168.xxx.xxx] (comp.mydomain.local [192.168.xxx.xxx])
    by mail.mydomain.com (Postfix) with ESMTPSA id 8043E81461
    for <xxxxx@gmail.com>; Thu, 19 Feb 2015 09:53:11 +0300 (MSK)

First and second 'recieved' are ok , but I need to get rid of unwanted received fields (localhost and some inner IP informations). Looking for some information and get:
Getting rid of 'received':

/etc/postfix/main.cf
  header_checks = regexp:/etc/postfix/header_checks

/etc/postfix/header_checks:
  /^Received: from .*by mail\.mydomain\.com \(Postfix\) with ESMTPSA/ IGNORE #inner info
  /^Received: from .*\[127\.0\.0\.1\].*by mail\.mydomain\.com.*/ IGNORE #all fields by my server containing [127.0.0.1]

Turn off adding 'recieved' fields by amavis:

/etc/amavis/conf.d/50-user:
  $allowed_added_header_fields{lc('Received')} = 0;

Check new header:

Received: by 10.27.178.10 with SMTP id b10csp1120450wlf;
        Fri, 20 Feb 2015 04:56:55 -0800 (PST)
Received: from mail.mydomain.com (mail.mydomain.com. [xxx.xxx.xxx.xxx])
        by mx.google.com with ESMTPS id wo5si15188206lbb.15.2015.02.20.04.56.54
        for <xxxxx@gmail.com>
        (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Fri, 20 Feb 2015 04:56:54 -0800 (PST)
Received: from localhost (localhost [127.0.0.1])
    by mail.mydomain.com (Postfix) with ESMTP id 813AE81467
    for <xxxxx@gmail.com>; Fri, 20 Feb 2015 15:56:28 +0300 (MSK)

Still 1 more unwanted recieved sad But how it could be? Check our recieved field:

postmap -q "Received: from localhost (localhost [127.0.0.1]) by mail.mydomain.com (Postfix) with ESMTP " regexp:/etc/postfix/header_checks
IGNORE

So i believe this Recieved is added after header_checks. Any idea how to remove it?

My temporary solution to not get in BL is editing

/etc/amavis/conf.d/05-node_id
  chomp($localhost_name = `localhost`); #before
  chomp($localhost_name = `hostname --fqdn`); #after

This changes affect to header:

Received: from mail.mydomain.com (localhost [127.0.0.1])
    by mail.mydomain.com (Postfix) with ESMTP id 813AE81467
    for <xxxxx@gmail.com>; Fri, 20 Feb 2015 15:56:28 +0300 (MSK)

Only after this my server stops to get to the Spamhaus BL.

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: Clean up header

Add to end of file /etc/amavis/50-user one line:

$localhost_name = $myhostname;

Restart amavis.

Before headers:

Received: from localhost (localhost [127.0.0.1])
    by mail.example.org (Postfix) with ESMTP id A64B8282059
    for <test@gmail.com>; Thu, 26 Feb 2015 12:42:53 +0300 (MSK)
Received: from mail.example.org ([127.0.0.1])
    by localhost (mail.example.org [127.0.0.1]) (amavisd-new, port 10024)
    with ESMTP id rpWu-a3f_r-F for <test@gmail.com>;

After headers:

Received: from mail.example.org (localhost [127.0.0.1])
    by mail.example.org (Postfix) with ESMTP id B63F8282266
    for <test@gmail.com>; Fri, 27 Feb 2015 10:25:03 +0300 (MSK)
Received: from mail.example.org ([127.0.0.1])
    by mail.example.org (mail.example.org [127.0.0.1]) (amavisd-new, port 10024)
    with ESMTP id FKSgsYnOOFCM for <test@gmail.com>;

3

Re: Clean up header

avenger_msoft wrote:

$localhost_name = $myhostname;

This works. Will add it in next release of iRedMail. Thanks for sharing. smile

4

Re: Clean up header

I think better continue in this thread. Solution of avenger_msoft does the same 'chomp($localhost_name = `hostname --fqdn`);' in 05-node_id and the headar is just like described.
According similar thread http://www.iredmail.org/forum/topic8806 … 27001.html I've changed my /etc/hosts
Before:

123.123.123.123 mail.example.org mail
127.0.0.1       localhost
127.0.1.1       mail.example.org localhost

After:

123.123.123.123 mail.example.org mail
127.0.0.1       mail.example.org
127.0.1.1       mail.example.org localhost

Result:

Received: from mail.example.org (unknown [127.0.0.1])
    by mail.example.org (Postfix) with ESMTP id B952481452
    for <test@gmail.com>; Wed, 11 Mar 2015 11:15:47 +0300 (MSK)

5

Re: Clean up header

You should copy /etc/hosts to /var/spool/postfix/etc/hosts too.

6

Re: Clean up header

ZhangHuangbin wrote:

You should copy /etc/hosts to /var/spool/postfix/etc/hosts too.

AFAIK Postfix updates it from /etc/hosts when starts up. Anyways, I reboot server, files are the same.

7

Re: Clean up header

Mef wrote:

AFAIK Postfix updates it from /etc/hosts when starts up. Anyways, I reboot server, files are the same.

Looks like script /etc/init.d/postfix on Debian/Ubuntu will copy /etc/hosts (and some others) to /var/spool/postfix/etc/ for you, but scripts on other Linux/BSD distributions don't do this.