Debian – Google rewriting Exim Mail as ‘root@empty’

debianeximg-suite

I have a Debian Jessie server running Exim 4, with GMail setup as the Smarthost. If I try to send mail with an external address (i.e. CanadianLuke@example.com), it works fine. If I send mail to root or canadianluke (local usernames), I get two messages: the message I sent, and an email that GMail automatically generates, saying that it can't deliver mail to root@empty. We are using Google Apps for Non-Profits.

The email comes through, so I know that it's not fully Exim4, but I'm not entirely convinced that it's entirely GMail.

The command I'm using to send emails on my terminal: mail root -s Test

Delivery to the following recipient failed permanently:

     root@empty

Technical details of permanent failure:
DNS Error: Address resolution of empty. failed: Domain name not found

----- Original message -----

DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=MYDOMAIN_COM.20150623.gappssmtp.com; s=20150623;
        h=from:to:subject:message-id:date;
        bh=YJWMysPl36audKpPjWIG/TOl/JVGuKuq1l4/HEAjxb8=;
        b=eIIQpLxw5TFAwnKw4P3gQpKlKbnf9I1PRpzfElBK4m+g+8cu/3z3hBFxMIMdV2Heli
         5CDCvVpaxbiqBJBcyeNnJubwyb8pir2CEnkiKaLJVJjTK3fZkpiI0KlTWkjilMnZeTLy
         SSzJdu437Bo2ONDY960+SX4cZtUE2p2fMcY7zhm8OTPWvXuDJ+DMoLVMuMfBfR+000dL
         ksNXGUD9teGOxYBV5a4c5/SPyeHXY++Pr8AOY+4lU9nt3OIocaozwMGfJOiV0MiiC4MZ
         w1UaXPjygFkzywsgjRbGyh483J0r4pS522fTUvz0qzAtMoIWmNOTCzAIulxxSQXb+hlp
         HG8Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:to:subject:message-id:date;
        bh=YJWMysPl36audKpPjWIG/TOl/JVGuKuq1l4/HEAjxb8=;
        b=gBolH/1kEUPQVIVrhMhtsOHaBHc9CIbEfqtAru5aJKSgoCst11qOUFQHC+tPrjVuhH
         s1JvVw7w6f05543JED9ak2SaQ5o5Iz6oWAkS3Z72MBwBaFlM144d/e4N64OYUG0Df4aR
         UDo/ryRdFOZ1WInOrTaoF9BWI/glLCtUPoadpqJ1utk74qEuZE4Ff3as/GjKAE5LXM3O
         Me27QYddAMMCdHi2DPtmkiM/3TosQjdaGv1QbGjk/ZS/q1HqdXCbZhjj65PwIiGDRxdk
         kw49ybPDjyoIFR5IzHM/vI7P3lC6LkXZq4zEgitBGuafwB52Luvl1jCTxUXZbLiODXko
         yDxQ==
X-Gm-Message-State: ALoCoQn4f0bfvp6Tk6pmiVZgxHs/bn8OVKale7+375O8j9UzvWgsYVSltXGIbvQQk5Fxi3DKGh5o
X-Received: by 10.140.94.116 with SMTP id f107mr417247qge.0.1447108430809;
        Mon, 09 Nov 2015 14:33:50 -0800 (PST)
Return-Path: <CanadianLuke@example.com>
Received: from example.com ([93.184.216.34])
        by smtp.gmail.com with ESMTPSA id 83sm102514qhw.27.2015.11.09.14.33.50
        for <root@empty>
        (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Mon, 09 Nov 2015 14:33:50 -0800 (PST)
From: root <CanadianLuke@example.com>
X-Google-Original-From: root <root@empty>
Received: from root by example.com with local (Exim 4.84)
        (envelope-from <root@empty>)
        id 1Zvv0W-0006Lj-Tf
        for root@empty; Mon, 09 Nov 2015 17:33:48 -0500
To: root@empty
Subject: Sup
Message-Id: <E1Zvv0W-0006Lj-Tf@example.com>
Date: Mon, 09 Nov 2015 17:33:48 -0500

Update. I got it to send mail again, but it's giving a new error. I added my username into /etc/aliases for where to send mail as root, and /etc/email-addresses is set to send mail destined for me to my regular email account (CanadianLuke@example.com).

# more exim4/update-exim4.conf.conf
dc_eximconfig_configtype='smarthost'
dc_other_hostnames=''
dc_local_interfaces='127.0.0.1'
dc_readhost='ex.com'
dc_relay_domains=''
dc_minimaldns='false'
dc_relay_nets=''
dc_smarthost='smtp.gmail.com::587'
CFILEMODE='644'
dc_use_split_config='true'
dc_hide_mailname='true'
dc_mailname_in_oh='true'
dc_localdelivery='mail_spool'

Now, the email is showing as an error from root@server.example.com, still the same DNS error: Address resolution of server.example.com failed: Domain name not found in Google Apps.

Below is a tail of my /var/log/exim4/mainlog, showing mail is in fact leaving the server:

2015-11-12 07:01:01 1ZwqYn-0001oN-2H <= canadianluke@example.com U=root P=local S=2598
2015-11-12 07:01:01 1ZwqYn-0001oN-2H gmail-smtp-msa.l.google.com [2607:f8b0:400c:c06::6d] Network is unreachable
2015-11-12 07:01:02 1ZwqYn-0001oN-2H => root@server.example.com R=smarthost T=remote_smtp_smarthost H=gmail-smtp-msa.l.google.com [74.125.141.108] X=TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128 DN="C=US,ST=California,L=Mountain View,O=Google Inc,CN=smtp.gmail.com" A=plain C="250 2.0.0 OK 1447329663 h144sm1989632vke.26 - gsmtp"
2015-11-12 07:01:02 1ZwqYn-0001oN-2H Completed

My /etc/aliases file:

# /etc/aliases
mailer-daemon: postmaster
postmaster: root
nobody: root
hostmaster: root
usenet: root
news: root
webmaster: root
www: root
ftp: root
abuse: root
noc: root
security: root
root: canadianluke
canadianluke: canadianluke@example.com

Best Answer

The email address root@empty is not a valid email address. The remote server is correct in returning an error email.

An email address generally needs to consist of three parts, separated by the at sign <@> and a dot <.>

The first part typically is some form of a user name, but could also be a function (sales, hr), or anything really (as long as your MTA knows what to do with it), the second part right after at sign <@> is the domain name and the last part right after the dot <.> is the TLD or top level domain. These can not be arbitrary for obvious reasons.

name@example.com

The MTA does not know where to send your email with address root@empty.

This might work on a local system when the MTA knows what to do with email addresses of that particular format, but once it leaves your local system it's just going to be refused and you get an error back.

What you need to do is to configure exim to either deliver emails with the format name@example (where example is your own domain) locally and not try to send them out, or configure exim to rewrite such emails with the correct format name@example.com and then send them out.

When you run dpkg-reconfigure exim4-config there is a question Other destinations for which mail is accepted: if there you add the domain(s) for which you want the system to be the final destination what you're trying to do should work. But you may do some hand editing of the configuration files.

Since you say you actually receive the email and get an error from the remote MTA you may just have to reconfigure exim to not send such emails out. The above I think might take care of that automagically.

Also see:

https://www.rfc-editor.org/rfc/rfc5321

https://www.rfc-editor.org/rfc/rfc2821

Update: Judging from your updated question it appears you either need to use the email address in the form of user@example.com or register server.example.com at google apps. I forgot exactly how to do this but I know it is possible to configure this. Of course make sure the DNS for server.example.com is set up correctly.

Regarding your last comment, did you try to add the following line into /etc/aliases

root: root@example.com

This would automatically tell exim to redirect mail destined to the root account on that system to be sent to root@example.com (or even root@server.example.com if you configured that in aliases).

Related Topic