# MX list for [domain]. points back to [server].[domain]



## gqgunhed (Jan 29, 2013)

I have the following setup here:

Main/physical machine:  *freebsd.gq.lan*
ezjail:                 *mail.gq.lan* with postfix+dovecot
... and some more ezjails, all on the main machine "freebsd.gq.lan"

On the host system I get lots of errors like:

```
freebsd sm-mta[91502]: r0T33fPQ091494: SYSERR(root): MX list for gq.lan. points back to freebsd.gq.lan
```
All other ezjails have no problems mailing to "@gq.lan", so I think the MX record should be fine.

`# dig MX gq.lan`
gives the entries [shortened]

```
;; QUESTION SECTION:
;gq.lan.                        IN      MX

;; ANSWER SECTION:
gq.lan.         3600    IN      MX      10 mail.gq.lan.
```
which is correct as I only have one mail-server/MX-record.

I think this is maybe an error based on 
a) my DNS configuration (howto check that?)
b) sendmail issue

All interfaces for the ezjails are aliases of the LAN-NIC, so yes, technically speaking the mail.gq.lan-NIC is also an interface of the host-system.

I am trying to solve this for some days no, but I am stuck. Any hints?


----------



## DutchDaemon (Jan 29, 2013)

Put the names your server is known as (its hostname and/or its published name) and the domains you're receiving email for, in /etc/mail/local-host-names, and restart Sendmail. That should take care of it.You'll have to figure out how this should be done inside and outside of your jails.


----------



## gqgunhed (Jan 30, 2013)

Will try that later today. 
Thanks.


----------



## gqgunhed (Jan 31, 2013)

Hmpf,
filled in my values into /etc/mail/local-host-names. No errors so far, but: The mails now get delivered to my host server itself. 
One should read the sendmail manual first.

I entered into /etc/mail/local-host-names the values for:

```
gq.lan
freebsd.gq.lan
freebsd
mail.gq.lan
mail
```

So my host freebsd.gq.lan thinks it should receive the emails for my jailed email-server mail.gq.lan as well.
Will do some more tests.


----------



## DutchDaemon (Jan 31, 2013)

That's why I told you to figure out what to put in the jail and on the host. If a jail handles a domain, configure only that domain as 'local' inside the jail.


----------



## gqgunhed (Jan 31, 2013)

The mail-jail runs Postfix, no sendmail.
All other jails and clients can send their emails without problems to internal and external email-addresses.
So I don't think the problem lies on the side of the mail-server (postfix receiving and relaying for all other devices).

The only host having problems is the host of the jail, complaining about "MX pointing back to self".
But I may be totally wrong. That is why I am stuck.
I will play around with the sendmail config (on the host) a little bit more. Maybe I can convince sendmail to send the email out anyways.


----------



## gqgunhed (Feb 3, 2013)

test must be run like: 

```
sendmail -An gunhed@gq.lan
```
, otherwise sendmail will send out the emails without problems. 
(-Am tells sendmail to use the sendmail.cf)

I modified my /etc/mail/mailertable according to https://www.sendmail.com/sm/open_source/docs/m4/mailertables.html.
I had an entry there reading:

```
.gq.lan       smtp:mail.gq.lan
```
I also tried changing to:

```
.gq.lan       relay:mail.gq.lan
```
all producing the same error mentioned above.

And after every change I did:

```
makemap hash /etc/mail/mailertable < /etc/mail/mailertable
/etc/rc.d/sendmail restart
```

Hmm, but I created some .cf and .submit.cf files in my /etc/mail. I think I have to check these...


----------



## gqgunhed (Feb 3, 2013)

results:
`# sendmail -Am [email]gunhed@gq.lan[/email]` produces the mentioned error, whereas
`# sendmail -Ac [email]gunhed@gq.lan[/email]` delivers email via mail.gq.lan without problems

man sendmail


> Parameters
> -Ac    Use submit.cf even if the operation mode does  not  indicate  an
> initial mail submission.
> 
> ...


----------



## gqgunhed (Feb 3, 2013)

rebuilt my configs in /etc/mail/ with `# make` and `# make install` and rehashed the mailertable.

instructions from: http://systems.takizo.com/tag/sendmail/


----------



## gqgunhed (Feb 3, 2013)

I solved (aka circumvented) my problem using mail/ssmtp as shown on http://www.freebsd.org/doc/handbook/outgoing-only.html.

Let's see if the automatic log emails will work, too.


----------



## gqgunhed (Feb 4, 2013)

Ok,
here's the solution that works for me:


```
portmaster mail/ssmtp
```
After that, use

```
cd /usr/ports/mail/ssmtp && make replace
```
to replace the symlinks to the original sendmail binaries with these from the ssmtp-port.

Now, add an entry in /usr/local/etc/ssmtp/revaliases, e.g. 
	
	



```
root:root@gq.lan:mail.gq.lan
```
This replaces the functionality of /etc/aliases.
Finally, edit the /usr/local/etc/ssmtp/ssmtp.conf to reflect the local settings.


----------



## slaru (Oct 21, 2016)

I believe I had the same problem, namely, an ezjail on my host system was the MTA for my domain and the host could not deliver mail to the jailed MTA.  I fixed the problem with one change to the default sendmail configuration.

To start, I ran `make` inside the `/etc/mail` directory to create a host specific sendmail config based on the defaults.  (I suppose if you have already customized your sendmail config this is not necessary.)  Then, in the `host.example.com.mc` file, I added the line

```
define(`confDONT_PROBE_INTERFACES', `true')
```
above the `define(`confCW_FILE', `-o /etc/mail/local-host-names')` line.  Then I installed the modified config with `make install` and restarted sendmail.  Now I do not have problems with the host system delivering to its jailed MTA.


----------

