1

The mail header "from" domain of any mail sent to our company's server is replaced by server's domain.

For example:

example@gmail.com send an email to our server(company.com). We see the sender of this email is example@company.com.

I do not know the reason. Please help me. Thanks!

mail system: sendmail + dovecot + saslauthd

sendmail.mc:

#-----------------------------------------------------------------------------
# $Sendmail: debproto.mc,v 8.14.3 2010-08-03 06:56:05 cowboy Exp $
#
# Copyright (c) 1998-2009 Richard Nelson.  All Rights Reserved.
#
# cf/debian/sendmail.mc.  Generated from sendmail.mc.in by configure.
#
# sendmail.mc prototype config file for building Sendmail 8.14.3
#
# Note: the .in file supports 8.7.6 - 9.0.0, but the generated
#   file is customized to the version noted above.
#
# This file is used to configure Sendmail for use with Debian systems.
#
# If you modify this file, you will have to regenerate /etc/mail/sendmail.cf
# by running this file through the m4 preprocessor via one of the following:
#   * make   (or make -C /etc/mail)
#   * sendmailconfig 
#   * m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
# The first two options are preferred as they will also update other files
# that depend upon the contents of this file.
#
# The best documentation for this .mc file is:
# /usr/share/doc/sendmail-doc/cf.README.gz
#
#-----------------------------------------------------------------------------
divert(0)dnl
#
#   Copyright (c) 1998-2005 Richard Nelson.  All Rights Reserved.
#
#  This file is used to configure Sendmail for use with Debian systems.
#
define(`_USE_ETC_MAIL_')dnl
include(`/usr/share/sendmail/cf/m4/cf.m4')dnl
include(`/etc/mail/sasl/sasl.m4')dnl
VERSIONID(`$Id: sendmail.mc, v 8.14.3-9.2ubuntu1 2010-08-03 06:56:05 cowboy Exp $')
OSTYPE(`debian')dnl
DOMAIN(`debian-mta')dnl
dnl # Items controlled by /etc/mail/sendmail.conf - DO NOT TOUCH HERE
undefine(`confHOST_STATUS_DIRECTORY')dnl        #DAEMON_HOSTSTATS=

dnl #
dnl # General defines
dnl #
dnl # SAFE_FILE_ENV: [undefined] If set, sendmail will do a chroot()
dnl #   into this directory before writing files.
dnl #   If *all* your user accounts are under /home then use that
dnl #   instead - it will prevent any writes outside of /home !
dnl #   define(`confSAFE_FILE_ENV',             `')dnl
dnl #
dnl # Daemon options - restrict to servicing LOCALHOST ONLY !!!
dnl # Remove `, Addr=' clauses to receive from any interface
dnl # If you want to support IPv6, switch the commented/uncommentd lines
dnl #
FEATURE(`no_default_msa')dnl

TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
dnl define(`confAUTH_OPTIONS', `A') dnl
define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
dnl DAEMON_OPTIONS(`Family=inet6, Name=MTA-v6, Port=smtp, Addr=::1')dnl
DAEMON_OPTIONS(`Family=inet,  Name=MTA-v4, Port=smtp, Addr=0.0.0.0')dnl
dnl DAEMON_OPTIONS(`Family=inet6, Name=MSP-v6, Port=submission, M=Ea, Addr=::1')dnl
DAEMON_OPTIONS(`Family=inet,  Name=MSP-v4, Port=submission, M=Ea Addr=0.0.0.0')dnl
dnl DAEMON_OPTIONS(`Family=inet,  Name=MSP, Port=25 M=Ea')dnl

define(`confDEF_USER_ID',``mail:mail'')dnl
undefine(`UUCP_RELAY')dnl
undefine(`BITNET_RELAY')dnl
define(`confRUN_AS_USER',`root:smmsp')dnl
define(`confTRUSTED_USER', `smmsp')dnl
define(`confTRUSTED_USER', `smmta')dnl
define(`confTO_CONNECT', `1m')dnl
define(`confTRY_NULL_MX_LIST',true)dnl
define(`confDONT_PROBE_INTERFACES',true)dnl
define(`PROCMAIL_MAILER_PATH',`/usr/bin/procmail')dnl
define(`ALIAS_FILE', `/etc/aliases')dnl
define(`STATUS_FILE', `/etc/mail/statistics')dnl
define(`UUCP_MAILER_MAX', `5000000')dnl
define(`confPRIVACY_FLAGS', `authwarnings,novrfy,noexpn,restrictqrun')dnl
dnl #define(QUEUE_DIR,`/var/spool/mqueue/q*')dnl
define(`confMAX_MESSAGE_SIZE',`40000000')dnl
dnl # added for dns problem defer
define(`confBIND_OPTS', `WorkAroundBrokenAAAA')dnl


dnl #
dnl # Be somewhat anal in what we allow
define(`confPRIVACY_FLAGS',dnl
`needmailhelo,needexpnhelo,needvrfyhelo,restrictqrun,restrictexpand,nobodyreturn,authwarnings')dnl
dnl #
dnl # Define connection throttling and window length
define(`confCONNECTION_RATE_THROTTLE', `15')dnl
define(`confCONNECTION_RATE_WINDOW_SIZE',`10m')dnl
dnl #
dnl # Features
dnl #
dnl # use /etc/mail/local-host-names
FEATURE(`use_cw_file')dnl
dnl FEATURE(`use_ct_file')dnl

dnl # Delay_checks allows sender<->recipient checking
FEATURE(local_procmail,`',`procmail -t -Y -a $h -d $u')dnl

dnl #
dnl # The access db is the basis for most of sendmail's checking
FEATURE(`access_db', , `skip')dnl

FEATURE(`blacklist_recipients')dnl
dnl # blacklist to stop spams
dnl #FEATURE(`dnsbl', `cblless.anti-spam.org.cn')dnl
dnl #FEATURE(`enhdnsbl', `cblplus.anti-spam.org.cn', `"Server address listed at cblplus.anti-spam.org.cn"', `t')dnl
FEATURE(`enhdnsbl', `zen.spamhaus.org', `"Spam blocked see: http://www.abuse.net/sbl.phtml?IP="$&{client_addr}', `t')dnl
dnl #FEATURE(`access_db',`hash -T<TMPF> -o /etc/mail/access.db')dnl


dnl #
dnl # The greet_pause feature stops some automail bots - but check the
dnl # provided access db for details on excluding localhosts...
FEATURE(`greet_pause', `1000')dnl 1 seconds
dnl #
dnl # Delay_checks allows sender<->recipient checking
FEATURE(`delay_checks', `friend', `n')dnl
dnl #
dnl # If we get too many bad recipients, slow things down...
define(`confBAD_RCPT_THROTTLE',`3')dnl
dnl #
dnl # Stop connections that overflow our concurrent and time connection rates
FEATURE(`conncontrol', `nodelay', `terminate')dnl
FEATURE(`ratecontrol', `nodelay', `terminate')dnl
dnl #
dnl # If you're on a dialup link, you should enable this - so sendmail
dnl # will not bring up the link (it will queue mail for later)
dnl define(`confCON_EXPENSIVE',`True')dnl
dnl #
dnl # Dialup/LAN connection overrides
dnl #
include(`/etc/mail/m4/dialup.m4')dnl
include(`/etc/mail/m4/provider.m4')dnl

FEATURE(`smrsh')dnl
FEATURE(`mailertable')dnl
FEATURE(`virtusertable',`hash -o /etc/mail/virtusertable.db')dnl
dnl # add 2013-11-8
FEATURE(masquerade_envelope)dnl
dnl MASQUERADE_DOMAIN(hotmail.com)dnl
MASQUERADE_DOMAIN_FILE(`/etc/mail/masquerade-domain')dnl
MASQUERADE_AS(xxx.xxx.edu.cn)dnl

dnl #
dnl # 
dnl # Also accept email sent to "localhost.localdomain" as local email.
dnl # 
LOCAL_DOMAIN(`xxx.xxx.edu.cn')dnl
LOCAL_DOMAIN(`xxx.xxx.cn')dnl
LOCAL_DOMAIN(`xxx.cs.xxx.edu.cn')dnl
LOCAL_DOMAIN(`xxx.cs.xxx.cn')dnl

dnl # Default Mailer setup
dnl #MAILER_DEFINITIONS
MAILER(`smtp')dnl
MAILER(`procmail')dnl
MAILER(`local')dnl

Two examples:

163:

From example@company.com  Wed Dec 21 21:47:26 2016 
Return-Path: <example@company.com> 
Received: from m13-141.163.com (m13-141.163.com [220.181.13.141]) 
    by company.com (8.14.3/8.14.3/Debian-9.1ubuntu1) with ESMTP id uBLDlPiQ013409 
    for <xxx@company.com>; Wed, 21 Dec 2016 21:47:26 +0800 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; 
    s=s110527; h=Date:From:Subject:MIME-Version:Message-ID; bh=hpaD0 
    qA4I59smafOVhBxwFe3a15FCNfA2uxigC6sgOY=; b=JdNTQe6QHM1TCcgvPCHtw 
    0Lkr1iMuJpydrsSpywGH8QnwV0hMucgh0IO+jg4THKW+2hr/IaVbQJoJabx2W/Mr 
    nQ2YWwc7ECDVaFqU9HJJygtqcrP3d2cp3qBbGlq/YVUUkXidTeX52kQStnULVBzk 
    FEJFuAYeRA/4XZyeo5LxNM= 
Received: from example$163.com ( [192.198.95.71, 54.215.2.217, 10.144.1.72] ) 
by ajax-webmail-wmsvr141 (Coremail) ; Wed, 21 Dec 2016 21:46:07 +0800 (CST) 
X-Originating-IP: [192.198.95.71, 54.215.2.217, 10.144.1.72] 
Date: Wed, 21 Dec 2016 21:46:07 +0800 (CST) 
From: "example" <example@company.com> 
To: "xxx@company.com" <xxx@company.com> 
Subject: aaaaa 
X-Priority: 3 
X-Mailer: Coremail Webmail Server Version SP_ntes V3.5 build 
20160729(86883.8884) Copyright (c) 2002-2016 www.mailtech.cn 163com 
X-CM-CTRLDATA: RB7qyGZvb3Rlcl9odG09MjcyNTo1Ng== 
Content-Type: multipart/alternative; 
    boundary="----=_Part_12111914_355555859.1482327967157" 
MIME-Version: 1.0 
Message-ID: <7e744d1.2de269.15921a1c5b6.Coremail.xysmlx@163.com> 
X-Coremail-Locale: zh_CN 
X-CM-TRANSID:jcGowACXpqKfh1pYSOaiAA--.29831W 
X-CM-SenderInfo: p01vzzr06rljoofrz/1tbiNQ1HvlSIRLiDogABsB 
X-Coremail-Antispam: 1U5529EdanIXcx71UUUUU7vcSsGvfC2KfnxnUU== 
Status: RO 
X-UID: 336                                                   
Content-Length: 4432

gmail:

From example@company.com  Wed Dec 21 22:52:39 2016 
Return-Path: <example@company.com> 
Received: from mail-ua0-f178.google.com (mail-ua0-f178.google.com [209.85.217.178]) 
    by company.com (8.14.3/8.14.3/Debian-9.1ubuntu1) with ESMTP id uBLEqbPm019461 
    for <xxx@company.com>; Wed, 21 Dec 2016 22:52:38 +0800 
Received: by mail-ua0-f178.google.com with SMTP id 2so79983525uax.2 
       for <xxx@company.com>; Wed, 21 Dec 2016 06:52:00 -0800 (PST) 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; 
       d=gmail.com; s=20161025; 
       h=mime-version:from:date:message-id:subject:to; 
       bh=+fBXgxbVSyjlxMpSNMOsZLbhE2bqAQI97mJviWO7ebE=; 
       b=l1SM9poejQhkOB7y725tK1K8oCsbxSENpl+po0nU+AHzyNE0BguFHgLLrFMj7vnuPG 
        ARR0mhWhVow3Pikzeq+IrymrsbnEqyOwgehR/ztTYDY8TPfpghK3O7eRPr9XVhC8oFs+ 
        Il9rCu324IljhOstd/5cWhGkwhA/m2F1bLUoxYw0O18GLVE85uQnH7PZe04W21vPLDVq 
        fuJlrbNFSo4Fxbe626IaS/1CVIUrs5Wkz1YExfa7pADbiqc3RNrEErBrk4FfWRPdHN/y 
        7z7PxqpHvBs+SG2IMx5eCRA5zdsczQvNXHIy3yIHvwkeydYi77PPzR8qUZ2pSfomzmKu 
        LKCg== 
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; 
       d=1e100.net; s=20161025; 
       h=x-gm-message-state:mime-version:from:date:message-id:subject:to; 
       bh=+fBXgxbVSyjlxMpSNMOsZLbhE2bqAQI97mJviWO7ebE=; 
       b=CzacaxE4CvL4uxlG4qUkbEm+vAiix3+UR+I7D0xechpMyOGoGrjE/rVfOXl/Zk+8Rr 
        +F4xjJ+kTd7jv1C5d1NGk7CtjMl8mZpUk2bE7WesYV8PryUbY7b6mHpB7XjL3J3AD90o 
        UVPpyX9vjeVJ89E03a1rg05yILGEHWh/E3+bByw68HPxdyCss2I0Tri98030QBWRHasj 
        7BX6qswHzpo2+87yvRpcsBqoSoKgz4L7ydPMt+zXCmxN2VCqw5MX6vLyzuaOIyWR6RFd 
        Uda7z9lqKw8bOo1ntxaMSTwiHmRWZyWtarvB/1MxPRySsJDIc+4tw1YLbfBNNYiWf3C8 
        /SMQ== 
X-Gm-Message-State: AIkVDXKc6Fge9ySWKwRQDYsVUzsuNqgZ9VBci7aM/TEGB915XFQonbYpgBCqBzht712z1QTbDXlrek9X6dKWfA== 
X-Received: by 10.176.85.139 with SMTP id v11mr632414uaa.7.1482331912496; Wed, 
21 Dec 2016 06:51:52 -0800 (PST) 
MIME-Version: 1.0 
Received: by 10.176.16.145 with HTTP; Wed, 21 Dec 2016 06:51:12 -0800 (PST) 
From: example <example@company.com> 
Date: Wed, 21 Dec 2016 22:51:12 +0800 
Message-ID: <CAO+bwXcoowGtdtZBsQB44K27gUtCJEbpuRKpPj=w66YDQE828g@mail.gmail.com> 
Subject: fdasfdasfdasdasffdas 
To: xxx@company.com
Content-Type: multipart/alternative; boundary=f403045e286e156bca05442c4b0d 
X-UID: 340                                                   
Status: RO 
Content-Length: 2500
  • Add the configuration of your MTA to the question. – Gerald Schneider Dec 22 '16 at 6:48
  • I have added the sendmail.mc file to the description. – xysmlx Dec 22 '16 at 7:22
2

Turn off the masquerading options:

You can have your host masquerade as another using

  MASQUERADE_AS(`host.domain')

This causes mail being sent to be labeled as coming from the indicated host.domain, rather than $j.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.