Subject: exim4 some config error causing error how to pinpoint

From: Harry Putnam <[email-masked]>
Date: Mon, 12 Sep 2016 21:55:20 -0400

I've attempted to setup exim4 on a second debian OS, using the
working configuration from the older one.

Before getting too detailed I think I see something in output of my
debug technique that indicated somewhere my host is telling exim the
wrong host name.

(dv is host with working config )

I use this technique; sending a mail like this:
mailx -v -s "TEST 160912_211756 dv" [email-masked] < ~/txtmsg.txt
                               
I run that command then watch the smtp output from the little
test script named `tmail'.

On the working host the first bit of output:

 $ tmail [email-masked]
sending like this:
mailx -v -s "TEST 160912_211756 dv" [email-masked] < ~/txtmsg.txt
LOG: MAIN
  <= harry@dv U=harry P=local S=546

[...]

Now the second, non-working host:

 tmail [email-masked]
sending like this: (Non-working host is `d2')
mailx -v -s "TEST 160912_211617 d2" [email-masked] < ~/txtmsg.txt
                           
LOG: MAIN      
  <= [email-masked] U=harry P=local S=440
 ^^^^^^^^^^^^^^^^^^^^^
Notice the above difference .. in the working host it shows
  harry@dv (hostname is dv.local.lan)
  In the non-working host:
  [email-masked] (hostname is d2.local.lan)

Somewhere in my setup exim4 is finding the hostname without the
separating dot in d2.local.lan   and is using d2local.lan

Which may be causing the failure:  Following the smtp otuput:

-------       -------       ---=---       -------       -------

 delivering 1bjcKi-0001Ey-9B
R: nonlocal for [email-masked]
LOG: MAIN
  ** [email-masked] R=nonlocal: Mailing to remote domains not supported
LOG: MAIN
  <= <> R=1bjcKi-0001Ey-9B U=Debian-exim P=local S=1650
LOG: MAIN
  Completed
delivering 1bjcKi-0001F0-Fy
R: nonlocal for [email-masked]
LOG: MAIN
  ** [email-masked] R=nonlocal: Mailing to remote domains not supported
LOG: MAIN
  Frozen (delivery error message)

------- ------- ---=--- ------- -------

Or am I making too much of the missing dot and it really is that I've
missed an important setting that lets exim4 deliver to outside of lan?

---

From: Liam O'Toole <[email-masked]>
Date: Tue, 13 Sep 2016 11:19:39 +0100

>  <= [email-masked] U=harry P=local S=440

Run 'dpkg-reconfigure exim4-config' as root on the second host to repair
the hostname. See §8.5.3. of the documentation[1] for details.

You can also inspect the working settings on the first machine using
'debconf-show exim4-config'.

1: https://www.debian.org/releases/stable/i386/ch08s05.html.en

-- 

Liam

---

From: Harry Putnam <[email-masked]>
Date: Wed, 14 Sep 2016 17:19:31 -0400

Liam O'Toole <[email-masked]> writes:

> dpkg-reconfigure exim4-config

Thanks, that was pretty painless.  And thanks for the url to the
documentation section.

I've now progressed on to where I was aiming for.

I wanted to have one debian box as main mail client.  Yet be able to
send mail from a couple of others.

I've managed to get that working by aiming the secondary hosts at the
main mail host as smarthost.  That main host is inturn aimed at an
internet smarthost.

So far all working except one glitch.

Here is the cast of characters:
HOST1 Main mail host
HOST2 secondary host
User1 HOST1
User2 HOST1
user HOST2

I can send a mail from HOST2 to a user on HOST1 using the correct
address.  user1@HOST1

That main host has only two users.  I can send mail from HOST2 to
only one of those users.  That is. if, from HOST2, I send mail
to a HOST1 user like:

  user1@HOST1   It arrives in user1 slot at /var/spool/mail/user1 on
HOST1. 

However If I try sending to user2@HOST1 it never gets there. Even
though the smtp output on sending HOST2 appears to be saying it was
sent and received successfully.

orignating on HOST2 

tmail user2@HOST1
sending like this:
mailx -v -s "TEST 160914_163910" user1@HOST1 < ~/txtmsg.txt
LOG: MAIN
  <= [email-masked] U=user1 P=local S=422

smtp output:

 delivering 1bkGxi-0002L3-U4
R: smarthost for user2@HOST1
T: remote_smtp_smarthost for user1@HOST1
Connecting to HOST1.local.lan [192.168.1.5]:25 ... connected
  SMTP<< 220 dv ESMTP Exim 4.86 Wed, 14 Sep 2016 16:47:36 -0400
  SMTP>> EHLO HOST2.local.lan
  SMTP<< 250-dv Hello HOST2.local.lan [192.168.1.17]
         250-SIZE 52428800
         250-8BITMIME
         250-PIPELINING
         250 HELP
  SMTP>> MAIL FROM:<[email-masked]> SIZE=1464
  SMTP>> RCPT TO:<user2@HOST1>
  SMTP>> DATA
  SMTP<< 250 OK
  SMTP<< 250 Accepted
  SMTP<< 354 Enter message, ending with "." on a line by itself
  SMTP>> writing message and terminating "."
  SMTP<< 250 OK id=1bkH5k-0008FT-UQ
  SMTP>> QUIT
LOG: MAIN
  => user2@HOST1 R=smarthost T=remote_smtp_smarthost H=HOST1.local.lan [192.168.1.5] C="250 OK id=1bkH5k-0008FT-UQ"
LOG: MAIN
  Completed

Mail never appears at HOST1 /var/spool/mail/user2

---

From: Liam O'Toole <[email-masked]>
Date: Thu, 15 Sep 2016 10:05:55 +0100

> sent and received successfully.

Does user2 appear in the file /etc/aliases on HOST1? Is there a
/home/user2/.forward file on that host? Either of those would cause mail
addressed to user2@HOST1 to be relayed to another user instead.

Is there anything suspicious in the file /var/log/exim4/mainlog on
HOST1?

-- 

Liam

---

From: Harry Putnam <[email-masked]>
Date: Thu, 15 Sep 2016 13:34:12 -0400

> Does user2 appear in the file /etc/aliases on HOST1? Is there a
No

> /home/user2/.forward file on that host? Either of those would cause mail
No

> Is there anything suspicious in the file /var/log/exim4/mainlog on
Yes, there is this bit that seems to indicate that the message is
being processed by procmail.

dv.local.lan is HOST1  smarthost set to smtp.gmail.com
d2.local.lan is HOST2  smarthost set to HOST1

There is a user named `harry' on both hosts.

-------       -------       ---=---       -------       ------- 
2016-09-15 12:40:29 1bkZi9-0000Ne-MU <= [email-masked] H=(d2.local.lan) [192.168.1.17] P=esmtp S=608 id=[email-masked]
2016-09-15 12:40:31 1bkZi9-0000Ne-MU => harry <harry@dv> R=procmail T=procmail_pipe
2016-09-15 12:40:31 1bkZi9-0000Ne-MU Completed
2016-09-15 12:52:31 Start queue run: pid=1574
2016-09-15 12:52:31 End queue run: pid=1574
-------       -------       ---=---       -------       ------- 

There is a ~/.procmailrc for user2 but no specifc recipe that would
grab mail addressed to USER2@HOST1 (harry@dv).

However my .procmailrc has a final rule that catches anything not
already handled:

  :0
  post_ex.in

However the mail addressed user2@host1 is not going to that inbox (or
any other) either.

But dropping that mystery for the time being there seems to be
something bigger happening.

Since my previous post I have found that all those test messages to
user2 and user1 on HOST1 from HOST2 are being sent out to the
HOST1 smarthost and piling up as undeleverable on a gmail account.  My
smarthost is smtp.gmail.com

I guess that does make sense.  However I guess I just supposed that
somehow HOST1 would magically know not to try to send mail from other
lan hosts addressed to users on HOST1, out to the internet smarthost.

Maybe I need some other mechanism for that to happen?

To summarize the setup again very briefly... since it seems to be
getting more confusing ... at least to me.

HOST1 is setup to relay mail from its users to an internet smarthost
(smtp.gmail.com).

HOST2 is setup to relay mail from its users to HOST1 as its smarthost

When I try to send a message from USER@HOST2 to USER@HOST1, instead of
just delivering to USER@HOST1 it appears to be sending that message on
to the gmail smtp server.

The local lan is not a real FQDN so not suprising that the gmail
server cannot deliver it.... but how to prevent that local mail from
being sent to gmail server to start with?

---

From: Liam O'Toole <[email-masked]>
Date: Fri, 16 Sep 2016 09:37:58 +0100

> There is a user named `harry' on both hosts.

You need to tell exim4 on HOST1 that it is the 'final destination' for
emails within your local network. If you go back through the debconf
questions for exim4-config, you'll be asked about 'Other destinations
for which mail is accepted'. In your case the answer should be
'*.local.lan'. Then local emails will no longer be forwarded upstream.
Obviously, you will need to ensure that the various local fully
qualified domain names are resolvable, either by running your own DNS or
maintaining /etc/host files correctly.

-- 

Liam