Search code examples
smtpeximdovecot

Exim (Dovecot authenticator) malformed sender address: "user@domain"@domain (should be: user@domain)


I'm running a mail server with CentOS 6.5 / Exim 4.72 / Dovecot 2.0.9, and have the following problem: when I send emails, from Thunderbird, say from the address [email protected], the email is delivered with the following headers (extract):

Return-path: <"[email protected]"@mydomain.com>
Envelope-to: [email protected]
...
Received: from host86-128-154-245.range86-128.btcentralplus.com ([86.128.154.245] helo=asus-i7.banchory)
  by mail.mydomain.com with esmtpsa (UNKNOWN:AES128-SHA:128)
  (Exim 4.72)
  (envelope-from <"[email protected]"@mydomain.com>)
  id 1Xjdoz-0005Zt-7M; Thu, 30 Oct 2014 01:42:37 +0100
Message-ID: <[email protected]>
...
From: Kalenz <[email protected]>
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.0
...
Sender: "[email protected]"@mydomain.com

You can probably see what it's doing wrong: everywhere it says "[email protected]"@mydomain.com it should actually be saying [email protected]. I don't know why it is doing that.

Most recipients accept this anyway, but a few more conservative mail hosts will reject these messages. Replies arrive ok 99% of the time; sometimes they cite my original message as being from: "[email protected]"@mydomain.com On Behalf Of [email protected].

I don't think it's Thunderbird, because this is not a problem with other mail servers (i.e., other addresses) from the same client.

From the Exim log (same message):

2014-10-30 01:42:37 1Xjdoz-0005Zt-7M <= "[email protected]"@mydomain.com H=host86-128-154-245.range86-128.btcentralplus.com (asus-i7.banchory) [86.128.154.245] P=esmtpsa X=UNKNOWN:AES128-SHA:128 A=dovecot_plain:[email protected] S=30908 [email protected]
2014-10-30 01:42:38 1Xjdoz-0005Zt-7M => me <[email protected]> R=dovecot_virtual_router T=dovecot_virtual_transport
2014-10-30 01:42:38 1Xjdoz-0005Zt-7M => [email protected] <[email protected]> R=dnslookup T=remote_smtp H=mail.hisdomain.com [12.34.56.78] X=TLSv1:DHE-RSA-AES256-SHA:256
2014-10-30 01:42:38 1Xjdoz-0005Zt-7M Completed

(That second line is a BCC to self.)

As you can see, Exim uses the Dovecot authenticator, and in the log file reports the correct user name at A=dovecot_plain:[email protected].

From /etc/exim.conf:

# Host's fully qualified canonical name
primary_hostname = mail.mydomain.com

# Our own mail domains:
domainlist local_domains = @ : localhost : localhost.localdomain : mydomain.com : otherdomain.com

# The domain to add to all unqualified addresses (defaults to primary_hostname):
qualify_domain = mydomain.com

...
# Dovecot authenticators ref. http://www.exim.org/exim-html-current/doc/html/spec_html/ch-the_dovecot_authenticator.html
dovecot_plain:
  driver = dovecot
  public_name = PLAIN
  server_socket = /var/run/dovecot/auth-client
  server_set_id = $auth1

There are no rewrite rules in exim.conf.

From Dovecot configuration in /etc/dovecot/conf.d/10-auth.conf:

# Default realm/domain to use if none was specified.
# This is used for both SASL realms and appending @domain to username in plaintext logins.
auth_default_realm = mydomain.com

# Space separated list of wanted authentication mechanisms:
#   plain login digest-md5 cram-md5 ntlm rpa apop anonymous gssapi otp skey gss-spnego
auth_mechanisms = plain

...

#!include auth-deny.conf.ext
#!include auth-master.conf.ext
#!include auth-system.conf.ext
#!include auth-sql.conf.ext
#!include auth-ldap.conf.ext
!include auth-passwdfile.conf.ext
#!include auth-checkpassword.conf.ext
#!include auth-vpopmail.conf.ext
#!include auth-static.conf.ext

I did try blanking out auth_default_realm, but that did not help.

Then to /etc/dovecot/conf.d/auth-passwdfile.conf.ext:

# cat auth-passwdfile.conf.ext
# Authentication for passwd-file users. Included from auth.conf.
# Note: if the user logs in as "[email protected]", then %u="[email protected]" and %n="billy".

passdb {
  driver = passwd-file
  args = username_format=%u /path/to/passdb
}

userdb {
  driver = passwd-file
  args = username_format=%u /path/to/passdb
}

And entries in that passdb file look like this:

[email protected]:{SHA512-CRYPT}[~~~]:dovecot:mail::/srv/mail/mydomain.com/me::

(N.B., I edited out the password hash, at [~~~].)

And this is where I'm stuck. I don't see Dovecot doing anything wrong (in any case, mail reception and POP/IMAP work fine), so I suspect an error in my Exim configuration.

I imagine I could put together a rewrite rule in Exim to fix the outgoing message headers, but I would rather get to the source of the problem. Any advice?


Solution

  • Sounds like an identical question is answered here (coincidentally, also by me) :

    https://serverfault.com/questions/617712/exim-appending-hostname-to-fully-qualified-sender-address/618398#618398

    https://serverfault.com/questions/502868/exim-virtual-domains-vs-main-domain-rewriting-rules/502894#502894