如何從標頭中刪除 Received: (from apache@localhost) 和 sendmail 版本

如何從標頭中刪除 Received: (from apache@localhost) 和 sendmail 版本

如何從郵件中刪除已收到的標頭?

我想隱藏 apache 使用者名稱和 sendmail 版本。

訊息(從 PHP 腳本發送):

Delivered-To: [email protected]
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: <[email protected]>
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 <[email protected]>
        (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 [email protected] 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 [email protected] designates 81.149.XXX.XXX as permitted sender) [email protected];
       dkim=temperror (no key for signature) [email protected]
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: [email protected]
Subject: Test subjecT
Date: Wed, 30 Sep 2015 14:15:42 +0100
From: Root User <[email protected]>
Message-ID: <512823cdf14f75789632427d632307b5@erp>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="iso-8859-1"

Test body 560be07ebabe4

請注意Received: internal info suppressed(這是我隱藏收到的標頭的嘗試之一)

我花了好幾個小時嘗試了一切...

改變在php.ini

sendmail_path = /usr/sbin/sendmail -t -i [email protected]

(它有效,因為我有 X-Authentication-Error 警告,我透過將 apache 添加到受信任的用戶來超越該警告)

改變在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

生成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
========================================================

我已經沒有想法了,我想做的就是擺脫這個標題:

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

我怎樣才能做到這一點?

我使用的是Centos 6.7

我真的不想使用 postfix,因為有些伺服器軟體已經在使用 sendmail,而且我不想安裝兩個 MTA

答案1

好的,我發現了問題。我不得不把

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

submit.mc也。

我花了幾個小時尋找解決方案,我不敢相信我在這裡發布問題後就找到了答案。

答案2

將其添加到 sendmail.mc 對我來說是更好的解決方案:

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

這有條件地查看 auth_type ,如果有身份驗證,它會顯示 localhost,如果沒有,就像訊息從外部到達一樣,您會得到正常接收的標頭。這絕對是你想要的。

參考與歸功於:在 Sendmail 中隱藏經過驗證的寄件者的 IP

相關內容