1

How can I remove Received headers from message?

I want to hide apache user name, and sendmail version.

Message (send from PHP script):

Delivered-To: peter@mydomain.co.uk
Received: by 10.182.138.73 with SMTP id qo9csp2588531obb;
        Wed, 30 Sep 2015 06:15:48 -0700 (PDT)
X-Received: by 10.194.209.240 with SMTP id mp16mr4259781wjc.100.1443618948845;
        Wed, 30 Sep 2015 06:15:48 -0700 (PDT)
Return-Path: <no-reply@mailer.mydomain.co.uk>
Received: from mailer.mydomain.co.uk (host81-149-XXX-XXX.in-addr.btopenworld.com. [81.149.XXX.XXX])
        by mx.google.com with ESMTPS id p10si35980619wik.84.2015.09.30.06.15.48
        for <peter@mydomain.co.uk>
        (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 30 Sep 2015 06:15:48 -0700 (PDT)
Received-SPF: pass (google.com: domain of no-reply@mailer.mydomain.co.uk designates 81.149.XXX.XXX as permitted sender) client-ip=81.149.XXX.XXX;
Authentication-Results: mx.google.com;
       spf=pass (google.com: domain of no-reply@mailer.mydomain.co.uk designates 81.149.XXX.XXX as permitted sender) smtp.mailfrom=no-reply@mailer.mydomain.co.uk;
       dkim=temperror (no key for signature) header.i=@mailer.mydomain.co.uk
Received: internal info suppressed
DKIM-Filter: OpenDKIM Filter v2.10.3 mailer.mydomain.co.uk t8UDFhWP002575
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
    d=mailer.mydomain.co.uk; s=default; t=1443618943;
    bh=g3nQPcNP98itYjSOtoKgMzN1zvSZ6LEJL6OFN1iIxG4=;
    h=To:Subject:Date:From:From;
    b=UMc4qr45/zHJtN0ehAZHFadX9MwW8HhSOMW+EPh257UVzptUvKNKR88hRdkQP27nz
     iRX9/+/L9PJEen751up4aHEI892AV30bapj8gtju/iUlbwMNBvJoMSoHw/hcN/FqB5
     jJwGUq3KraD67AvLsRPCJhpLxWmNB5Dt7/YdXLiI=




// I want to get rid of this!

Received: (from apache@localhost)
    by mailer.mydomain.co.uk (8.14.4/8.14.4/Submit) id t8UDFgZp002574;
    Wed, 30 Sep 2015 14:15:42 +0100





To: peter@mydomain.co.uk
Subject: Test subjecT
Date: Wed, 30 Sep 2015 14:15:42 +0100
From: Root User <no-reply@mailer.mydomain.co.uk>
Message-ID: <512823cdf14f75789632427d632307b5@erp>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="iso-8859-1"

Test body 560be07ebabe4

please notice Received: internal info suppressed (its one of my attempts to hide received headers)

I tried everything for hours...

Changes in php.ini:

sendmail_path = /usr/sbin/sendmail -t -i -fno-reply@mailer.mydomain.co.uk

(it works because I had X-Authentication-Error warning which I suprassed by adding apache to trusted users)

Changes in sendmail.mc:

MASQUERADE_AS(`mailer.mydomain.co.uk')dnl
FEATURE(masquerade_envelope)dnl
FEATURE(masquerade_entire_domain)dnl
FEATURE(allmasquerade)dnl 
MASQUERADE_DOMAIN(localhost)dnl
MASQUERADE_DOMAIN(localhost.localdomain)dnl
MASQUERADE_DOMAIN(erp.mydomain.co.uk)dnl
define(`confDOMAIN_NAME', `mailer.mydomain.co.uk')dnl
define(`confRECEIVED_HEADER', `internal info suppressed')dnl

Generated sendmail.cf:

#########################
#   Format of headers   #
#########################

H?P?Return-Path: <$g>
HReceived: internal info suppressed
H?D?Resent-Date: $a
H?D?Date: $a
H?F?Resent-From: $?x$x <$g>$|$g$.
H?F?From: $?x$x <$g>$|$g$.
H?x?Full-Name: $x
# HPosted-Date: $a
# H?l?Received-Date: $b
H?M?Resent-Message-Id: <$t.$i@$j>
H?M?Message-Id: <$t.$i@$j>

/etc/hosts:

127.0.0.1   mailer.mydomain.co.uk localhost localhost.localdomain localhost4 localhost4.localdomain4 erp 192.168.1.100 erp.mydomain.co.uk
::1         mailer.mydomain.co.uk localhost localhost.localdomain localhost6 localhost6.localdomain6

hostname -f:

mailer.mydomain.co.uk

sendmail -d0.4 -bv root:

Version 8.14.4
 Compiled with: DNSMAP HESIOD HES_GETMAILHOST LDAPMAP LOG MAP_REGEX
        MATCHGECOS MILTER MIME7TO8 MIME8TO7 NAMED_BIND NETINET NETINET6
        NETUNIX NEWDB NIS PIPELINING SASLv2 SCANF SOCKETMAP STARTTLS
        TCPWRAPPERS USERDB USE_LDAP_INIT
Canonical name: mailer.mydomain.co.uk
 UUCP nodename: erp.mydomain.co.uk
    a.k.a.: localhost
    a.k.a.: localhost.localdomain
    a.k.a.: localhost4
    a.k.a.: localhost4.localdomain4
    a.k.a.: erp
    a.k.a.: 192.168.1.100
    a.k.a.: erp.mydomain.co.uk
    a.k.a.: [127.0.0.1]

============ SYSTEM IDENTITY (after readcf) ============
      (short domain name) $w = mailer
  (canonical domain name) $j = mailer.mydomain.co.uk
         (subdomain name) $m = mydomain.co.uk
              (node name) $k = erp.mydomain.co.uk
========================================================

I ran out of ideas and all I want to do is get rid of this header:

Received: (from apache@localhost)
    by mailer.mydomain.co.uk (8.14.4/8.14.4/Submit) id t8UDFgZp002574;
    Wed, 30 Sep 2015 14:15:42 +0100

How can I do that?

I am using Centos 6.7

I don't really want to use postfix because some of server software is using sendmail already and I don't want to have two MTA installed

Peter
  • 167
  • 1
  • 3
  • 16

2 Answers2

2

Ok I found the issue. I had to put

define(`confRECEIVED_HEADER', `internal info suppressed')dnl

Into submit.mc as well.

I was looking for solution for hours I can't believe I figured it out just after I posted question here.

Peter
  • 167
  • 1
  • 3
  • 16
  • Hi, I have the same issue. What should that internal info suppressed actually be? – Shivam Paw Aug 27 '16 at 16:22
  • @ShivamPaw this is literal line. `internal info suppressed` is `internal info suppressed` – Peter Aug 28 '16 at 15:57
  • Ah ok. My emails were going into spam with that as well as before. – Shivam Paw Aug 28 '16 at 22:48
  • 1
    Peter's response works. FYI - I was sending an email from Apache server on EC2 PHP7.2. I set up my SPF records with my DNS. Everytime that I sent an email, it was received as NEUTRAL. When I tried Peter's trick, it cleaned up my SPF issue, as the RECEIVED_HEADER is required to submit the accurate IP address, which GMAIL checks. Hopefully this will save you the 15 hours I spent debugging this SOB. – user2404354 Sep 25 '19 at 18:20
  • @user2404354 I think people who know all that postfix/sendmail config stuff should be called "fellowship of the ring" and should be send to mordor to destroy it so we can make something new – Peter Sep 27 '19 at 22:23
1

Adding this to sendmail.mc was a better solution for me:

define(`confRECEIVED_HEADER',`$?{auth_type}from auth (localhost [127.0.0.1]) $|_REC_HDR_$.
    _REC_BY_
    _REC_TLS_
    _REC_END_')

This conditionally looks at auth_type and if there was an authentication, it shows localhost, and if not, as in, if the message arrived from the outside, you get the normal received headers. This is definitely what you want.

Reference and credit to: Suppress IP of authenticated senders in Sendmail

Michael Grant
  • 203
  • 1
  • 7