I currently have two servers
first.mydomain.com
(ip:A.B.C.28) andsecond.mydomain.com
(ip:A.B.C.30)
Both servers have DNS and reverse dns entries, e.g. A.B.C.30 -> second.mydomain.com
The first.mydomain.com
– handles all emails from/to the mydomain.com (e.g. the MX for mydomain.com
pointing to first.mydomain.com
)
The second
is configured (exim/dovecot) for handling emails for two other domains. (virt1.com
and virt2.com
). MX records are OK,
virt1.com mail is handled by 100 second.mydomain.com
All basic things works (TLS, dovecot-auth.. etc..) Receiving email is OK to – delivering into /home/mail/virt1.com/user/Maildir
. Outgoing mail is delivering too (but strange), so routers, and transports works, but:
For example, when: the user@virt1.com
sending email to someuser@example.com
via second.mydomain.com
, got strange things in the headers.
Return-Path: <"user@virt1.com"@mydomain.com>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ??? - added mydomain
Received: ... deleted ...
Received: ... deleted ...
Received: from somedsl.someisp.com ([X.X.X.X]:21563 helo=marvin.local)
by second.mydomain.com with esmtpsa (TLSv1:DHE-RSA-CAMELLIA256-SHA:256)
(Exim 4.80.1 (FreeBSD))
(envelope-from <"user@virt1.com"@second.mydomain.com>)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ??? added FQDN
id 1UVf91-000ALf-fb
for someuser@example.com; Fri, 26 Apr 2013 11:40:43 +0200
Date: Fri, 26 Apr 2013 11:40:42 +0200
From: username <user@virt1.com>
Reply-To: user@virt1.com
To: someuser@example.com
Subject: test message
Sender: "user@virt1.com"@second.mydomain.com
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ??? added the FQDN again
start of my exim config is:
local_interfaces = A.B.C.30
primary_hostname = second.mydomain.com
domainlist local_domains = dsearch;/etc/mail/virtual #each domain has its own subdir
Yet, haven't any rewriting rules.
Questions:
- should i set the
smtp_active_hostname
to something, instead ofsecond.mydomain.com
? - need setup some heeader rewiting rules? (probably yes)
- what else i should check?
- some idea how to rid off the above weird headers?
The above is running in one freebsd jail, but it probably doesn't matter…
Best Answer
The first mail servers (of which Exim is derived from a very early one) were designed at a time when it was common for an email address for userX@example.com to belong to a real unix user named "userX". As such, when it constructs the Sender header and other headers, it would use the username @ default_domainname. The username part is referred to in Exim as the local_part.
In modern systems, it is much more common to have virtual users, where an exim server can receive email to a domain that is not the default domain, and the local_part is likely not a valid local user, or there may be multiple email addresses all with the same local_part. In systems like this, instead of authenticating as "userX", it's more common to authenticate as "userX@example.com". Exim internally will treat that whole string as the username unless you configure it otherwise.
http://www.exim.org/exim-html-current/doc/html/spec_html/ch-message_processing.html#SECTsubmodnon
The
control = submission
line tells exim to apply certain fixups to the message that gets submitted, including creating those headers you mentioned. Change it to:control = submission/sender_retain
to indicate that you want Exim to treat the submitted name as the full userX@example.com instead of just the local_part, meaning exim won't try to append the default domain name to what was submitted. The exim documentation linked above has a lot of great detail on this whole message submission and fixup process.