# Sendmail relay



## Avirdoz (Apr 11, 2011)

Hello. I have a domain with gmail MX records. When I send mail to this domain, it delivers into local mailbox. local-host-names empty.
Maillog:

```
Apr 11 11:38:37 mediamenu sendmail[79080]: p3B8cbQE079080: from=qwerty, size=9437, class=0, nrcpts=1, msgid=
<201104110838.p3B8cbQE079080@mediamenu.sterch.net>, relay=root@localhost
Apr 11 11:38:37 mediamenu sm-mta[79081]: p3B8cbVR079081: from=<qwerty@mediamenu.sterch.net>, size=9777, class=0, nrcpts=1, msgid=
<201104110838.p3B8cbQE079080@mediamenu.sterch.net>, proto=ESMTP, daemon=Daemon0, relay=localhost [127.0.0.1]
Apr 11 11:38:37 mediamenu sendmail[79080]: p3B8cbQE079080: to=qwerty@sterch.net, ctladdr=qwerty (1002/0), delay=00:00:00, xdelay=00:00:00, 
mailer=relay, pri=39437, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (p3B8cbVR079081 Message accepted for delivery)
Apr 11 11:38:37 mediamenu sm-mta[79082]: p3B8cbVR079081: to=<qwerty@sterch.net>, ctladdr=<qwerty@mediamenu.sterch.net> (1002/0), delay=00:00:00, 
xdelay=00:00:00, mailer=local, pri=40051, relay=local, dsn=2.0.0, stat=Sent
```


----------



## lbol (Apr 11, 2011)

Looks like the machine you sent from is a host in domain sterch.net and accepts mails sent to this domain.
You need to provide more information,. e.g. what does `% host -t mx sterch.net` return on your system


----------



## Avirdoz (Apr 11, 2011)

lbol said:
			
		

> Looks like the machine you sent from is a host in domain sterch.net and accepts mails sent to this domain.
> You need to provide more information,. e.g. what does `% host -t mx sterch.net` return on your system


Thank you for your reply.

[CMD=""]# host -t mx sterch.net[/CMD]

```
sterch.net mail is handled by 40 ASPMX2.GOOGLEMAIL.COM.
sterch.net mail is handled by 50 ASPMX3.GOOGLEMAIL.COM.
sterch.net mail is handled by 10 ASPMX.L.GOOGLE.COM.
sterch.net mail is handled by 20 ALT1.ASPMX.L.GOOGLE.COM.
sterch.net mail is handled by 30 ALT2.ASPMX.L.GOOGLE.COM.
```


----------



## lbol (Apr 11, 2011)

to trace down the issue you can run sendmail in address test mode
`% sendmail -bt`
at the prompt enter 
	
	



```
$=w
```
this will show what sendmail considers to be local (host names, domains, IP addresses)
if your host or domain shows up in this list you have added it somewhere in your configuration to class w

to test which delivery agent will be used by sendmail for a given address enter

```
3,0 <recipient email address>
```


----------



## Avirdoz (Apr 12, 2011)

lbol said:
			
		

> to trace down the issue you can run sendmail in address test mode
> `% sendmail -bt`
> at the prompt enter
> 
> ...


Thank for your reply.
When I checked class w, I saw a record "sterch.net", but in config of sendmail no directives with "sterch.net" and my hostname isn't sterch.net. How to remove this host from class w?


----------



## lbol (Apr 12, 2011)

The question is why has sterch.net been added to class w.

Sendmail populates class w in several steps. First of all it will call gethostbyname(3) and getipnodebyname(3) to find all known aliases for the local machine on all interfaces. The argument given to gethostbyname(3) is $w (the short name of the host).

Class w can also be set in sendmail.cf using directive C, e.g. 
	
	



```
Cw myhost
```

It can also be set in sendmail.mc with LOCAL_DOMAIN like 
	
	



```
LOCAL_DOMAIN(`myhost')
```

To see all aliases known by sendmail run `% sendmail -bt -d0.4`


----------



## Avirdoz (Apr 12, 2011)

[CMD=""]# sendmail -bt -d0.4[/CMD]

```
Version 8.14.3
 Compiled with: DNSMAP LOG MAP_REGEX MATCHGECOS MILTER MIME7TO8 MIME8TO7
                NAMED_BIND NETINET NETINET6 NETUNIX NEWDB NIS PIPELINING SCANF
                TCPWRAPPERS USERDB XDEBUG
Canonical name: mediamenu.sterch.net
 UUCP nodename: mediamenu.sterch.net
        a.k.a.: sterch.net
        a.k.a.: [IPv6:fe80::1]
        a.k.a.: [IPv6:::1]
        a.k.a.: [127.0.0.1]
        a.k.a.: [10.0.0.33]

============ SYSTEM IDENTITY (after readcf) ============
      (short domain name) $w = mediamenu
  (canonical domain name) $j = mediamenu.sterch.net
         (subdomain name) $m = sterch.net
              (node name) $k = mediamenu.sterch.net
========================================================

ADDRESS TEST MODE (ruleset 3 NOT automatically invoked)
Enter <ruleset> <address>
```
Now I add to .mc file 
	
	



```
LOCAL_DOMAIN(`mediamenu.sterch.net')
```
 and *make install restart* sendmail. But in class w I see the same.


----------



## lbol (Apr 12, 2011)

Adding 





> ```
> LOCAL_DOMAIN(`mediamenu.sterch.net')
> ```


 to your .mc file will not solve your problem. 
Can you provide your .mc file.


----------



## Avirdoz (Apr 12, 2011)

lbol said:
			
		

> Adding  to your .mc file will not solve your problem.
> Can you provide your .mc file.


[CMD=""]> cat /etc/mail/mediamenu.sterch.net.mc | grep -v ^dnl | grep -v ^# | grep .[/CMD]

```
divert(-1)
divert(0)
VERSIONID(`$FreeBSD: src/etc/sendmail/freebsd.mc,v 1.29 2003/12/24 21:15:09 gshapiro Exp $')
OSTYPE(freebsd5)
DOMAIN(generic)
FEATURE(access_db, `hash -o -T<TMPF> /etc/mail/access')
FEATURE(blacklist_recipients)
FEATURE(local_lmtp)
FEATURE(mailertable, `hash -o /etc/mail/mailertable')
FEATURE(virtusertable, `hash -o /etc/mail/virtusertable')
define(`confCW_FILE', `-o /etc/mail/local-host-names')
DAEMON_OPTIONS(`Name=IPv4, Family=inet')
DAEMON_OPTIONS(`Name=IPv6, Family=inet6, Modifiers=O')
define(`confBIND_OPTS', `WorkAroundBrokenAAAA')
define(`confNO_RCPT_ACTION', `add-to-undisclosed')
define(`confPRIVACY_FLAGS', `authwarnings,noexpn,novrfy')
define(`confQUEUE_LA', `100')
define(`confREFUSE_LA', `80')
define(`confMAX_MESSAGE_SIZE',`12000000')
MAILER(local)
MAILER(smtp)
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
LOCAL_DOMAIN(`mediamenu.sterch.net')
```


----------



## lbol (Apr 12, 2011)

I can't see anything wrong in your .mc file. 
Do you have an entry in /etc/hosts or an A record for sterch.net in DNS?

This is the last thing that comes to my mind


----------



## Avirdoz (Apr 13, 2011)

lbol said:
			
		

> I can't see anything wrong in your .mc file.
> Do you have an entry in /etc/hosts or an A record for sterch.net in DNS?
> 
> This is the last thing that comes to my mind




[CMD=""]> cat /etc/hosts | grep -v ^#
[/CMD]

```
::1                     localhost #localhost.sterch.net
127.0.0.1               localhost #localhost.sterch.net
```
In DNS i have A record for sterch.net to this server and that record is in use by webserver.


----------



## lbol (Apr 13, 2011)

> In DNS i have A record for sterch.net to this server and that record is in use by webserver.


As sendmail probes every interface it adds all IP adresses and names to class w

However, you can tell sendmail to not probe interfaces using 
	
	



```
define(`confDONT_PROBE_INTERFACES', `true')dnl
```
 in sendmail.mc
In this case add every domain/host for which to want local delivery to /etc/mail/local-host-names


----------



## Avirdoz (Apr 13, 2011)

lbol said:
			
		

> As sendmail probes every interface it adds all IP adresses and names to class w
> 
> However, you can tell sendmail to not probe interfaces using
> 
> ...


Thank for answer. I done this and now in maillog:

```
Apr 13 14:53:25 mediamenu sm-mta[99543]: p3DBrOhh099543: from=<qwerty@mediamenu.sterch.net>, size=9776, class=0, nrcpts=1, msgid=<201104131153.p3DBrOoo099542@mediamenu.sterch.net>, proto=ESMTP, daemon=Daemon0, relay=localhost [127.0.0.1]
Apr 13 14:53:25 mediamenu sendmail[99542]: p3DBrOoo099542: to=qwerty@sterch.net, ctladdr=qwerty(1002/0), delay=00:00:01, xdelay=00:00:01, mailer=relay, pri=39436, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (p3DBrOhh099543 Message accepted for delivery)
Apr 13 14:53:25 mediamenu sm-mta[99545]: p3DBrOhh099543: to=<qwerty@sterch.net>, ctladdr=<qwerty@mediamenu.sterch.net> (1002/0), delay=00:00:01, xdelay=00:00:00, mailer=smtp, pri=39776, relay=esmtp, dsn=5.1.2, stat=Host unknown (Name server: esmtp: host not found)
Apr 13 14:53:25 mediamenu sm-mta[99545]: p3DBrOhh099543: p3DBrPhh099545: DSN: Host unknown (Name server: esmtp: host not found)
Apr 13 14:53:25 mediamenu sm-mta[99545]: p3DBrPhh099545: to=<qwerty@mediamenu.sterch.net>, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=40800, relay=local, dsn=2.0.0, stat=Sent
```


----------



## lbol (Apr 13, 2011)

It's almost not possible to help any further unless I know the whole setup of your environment (IP configuration, DNS setup, ...).  Looks like you have a DNS issue now.


----------

