# sendmail using relay host



## fuhdan (Nov 18, 2010)

Hi all
I try to configure my sendmail, to use the companies Relay Host. So I was following the post, that I found here. But sendmail still tries to resolfe the mx records.

I triy to send a email like this:

```
/usr/sbin/sendmail -f daniel.fuhrer@<company>.com daniel@<rcpt> < testmail.txt
```

In the Logfiles I find this:

```
Nov 18 06:58:45 dev sendmail[4214]: oAI5wi6t004214: from=xxx@<company>.com, size=61, class=0, nrcpts=1, msgid=
<201011180558.oAI5wi6t004214@dev.company.com>, relay=root@localhost

Nov 18 06:58:46 dev sendmail[4214]: oAI5wi6t004214: to=daniel@<rcpt>, ctladdr=daniel.fuhrer@<company>.com (0/0), delay=00:00:02, 
xdelay=00:00:01, mailer=relay, pri=30061, relay=mail20.<company>.com., dsn=5.1.2, stat=Host unknown (Name server: mail20.<company>.com.: host 
not found)

Nov 18 06:58:46 dev sendmail[4214]: oAI5wi6t004214: oAI5wi6u004214: DSN: Host unknown (Name server: mail20.<company>.com.: host not found)

Nov 18 06:58:46 dev sendmail[4214]: oAI5wi6u004214: to=daniel.fuhrer@<company>.com, delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=31085, 
relay=mail10.<company>.com., dsn=5.1.2, stat=Host unknown (Name server: mail10.<company>.com.: host not found)

Nov 18 06:58:46 dev sendmail[4214]: oAI5wi6u004214: oAI5wi6v004214: return to sender: Host unknown (Name server: mail10.<company>.com.: host 
not found)

Nov 18 06:58:47 dev sm-mta[4215]: oAI5wklo004215: from=<>, size=3588, class=0, nrcpts=1, msgid=<201011180558.oAI5wi6v004214@dev.<subdomain>.
<company>.com>, proto=ESMTP, daemon=IPv4, relay=localhost [127.0.0.1]

Nov 18 06:58:47 dev sendmail[4214]: oAI5wi6v004214: to=postmaster, delay=00:00:01, xdelay=00:00:01, mailer=relay, pri=32109, relay=[127.0.0.1] 
[127.0.0.1], dsn=2.0.0, stat=Sent (oAI5wklo004215 Message accepted for delivery)

Nov 18 06:58:47 dev sm-mta[4216]: oAI5wklo004215: to=root, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=33812, relay=local, dsn=2.0.0, 
stat=Sent
```

This are the configfiles I have on my system:

```
dev# ll /etc/mail
total 402
-rw-r--r--  1 root  wheel   6818 Jul 19 04:17 Makefile
-rw-r--r--  1 root  wheel   2905 Jul 19 04:17 README
-rw-r--r--  1 root  wheel    634 Jul 19 04:17 access.sample
-rw-r--r--  1 root  wheel   1667 Jul 19 04:17 aliases
-rw-r-----  1 root  wheel  65536 Oct  5 08:59 aliases.db
-rw-r--r--  1 root  wheel  58245 Nov 17 17:52 dev.<subdomain>.<company>.com.cf
-rw-r--r--  1 root  wheel   4107 Nov 17 17:52 dev.<subdomain>.<company>.com.mc
-rw-r--r--  1 root  wheel  40706 Nov 17 17:52 dev.<subdomain>.<company>.com.submit.cf
-r--r--r--  1 root  wheel    901 Nov 17 17:52 dev.<subdomain>.<company>.com.submit.mc
-rw-r--r--  1 root  wheel  58287 Nov 17 17:10 freebsd.cf
-rw-r--r--  1 root  wheel   4107 Nov 17 17:52 freebsd.mc
-r--r--r--  1 root  wheel  40762 Nov 17 17:10 freebsd.submit.cf
-r--r--r--  1 root  wheel    901 Jul 19 04:17 freebsd.submit.mc
-r--r--r--  1 root  wheel   5657 Jul 19 04:17 helpfile
-rw-r--r--  1 root  wheel    409 Jul 19 04:17 mailer.conf
-rw-r--r--  1 root  wheel    253 Jul 19 04:17 mailertable.sample
-rw-r--r--  1 root  wheel  58287 Nov 17 17:09 sendmail.cf
-r--r--r--  1 root  wheel  40762 Nov 17 17:10 submit.cf
-rw-r--r--  1 root  wheel    582 Jul 19 04:17 virtusertable.sample
```

And this is the config, which is needed for the relaiing (as far as I understand it:

```
dev# cat /etc/mail/dev.<subdomain>.<company>.com.cf | grep DS
DS<IP>

dev# cat /etc/mail/dev.<subdomain>.<company>.com.submit.cf | grep DS
DS<IP>

dev# cat /etc/mail/freebsd.submit.cf  | grep DS
DS<IP>

dev# cat /etc/mail/sendmail.cf  | grep DS
DS<IP>

dev# cat /etc/mail/submit.cf  | grep DS
DS<IP>
```

On my system is sendmail running like this:

```
dev# ps ax | grep sendmail
 1217  ??  Ss     0:00.87 sendmail: accepting connections (sendmail)
 1221  ??  Is     0:00.04 sendmail: Queue runner@00:30:00 for /var/spool/clientmqueue (sendmail)
 4249   0  S+     0:00.01 grep sendmail

dev# sockstat -4 -p 25
USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS      
root     sendmail   1217  4  tcp4   *:25                  *:*
```

And this is the software I use:

```
dev# uname -a
FreeBSD dev.<subdomain>.<company>.com 8.1-RELEASE FreeBSD 8.1-RELEASE #0: Mon Jul 19 02:36:49 UTC 2010     
[email]root@mason.cse.buffalo.edu[/email]:/usr/obj/usr/src/sys/GENERIC  amd64

dev# /usr/sbin/sendmail -v -d0.1 < /dev/null
Version 8.14.4
 Compiled with: DNSMAP LOG MAP_REGEX MATCHGECOS MILTER MIME7TO8 MIME8TO7
		NAMED_BIND NETINET NETINET6 NETUNIX NEWDB NIS PIPELINING SCANF
		STARTTLS TCPWRAPPERS USERDB XDEBUG

============ SYSTEM IDENTITY (after readcf) ============
      (short domain name) $w = dev
  (canonical domain name) $j = dev.<subdomain>.<company>.com
         (subdomain name) $m = <subdomain>.<company>.com
              (node name) $k = dev.<subdomain>.<company>.com
========================================================

Recipient names must be specified
```

If I test the mailflow, it looks that sendmail finds the relay host:

```
dev# /usr/sbin/sendmail -bt
ADDRESS TEST MODE (ruleset 3 NOT automatically invoked)
Enter <ruleset> <address>
> 3,0 [email]isaac@linux.org.au[/email]
canonify           input: isaac @ linux . org . au
Canonify2          input: isaac < @ linux . org . au >
linux.org.au: Name server timeout
Canonify2        returns: isaac < @ linux . org . au >
canonify         returns: isaac < @ linux . org . au >
== Ruleset 3,0 (3) status 75
parse              input: isaac < @ linux . org . au >
Parse0             input: isaac < @ linux . org . au >
Parse0           returns: isaac < @ linux . org . au >
ParseLocal         input: isaac < @ linux . org . au >
ParseLocal       returns: isaac < @ linux . org . au >
Parse1             input: isaac < @ linux . org . au >
Mailertable        input: < linux . org . au > isaac < @ linux . org . au >
Mailertable        input: linux . < org . au > isaac < @ linux . org . au >
Mailertable        input: linux . org . < au > isaac < @ linux . org . au >
Mailertable      returns: isaac < @ linux . org . au >
Mailertable      returns: isaac < @ linux . org . au >
Mailertable      returns: isaac < @ linux . org . au >
MailerToTriple     input: < <IP> > isaac < @ linux . org . au >
MailerToTriple   returns: $# relay $@ <IP> $: isaac < @ linux . org . au >
Parse1           returns: $# relay $@ <IP> $: isaac < @ linux . org . au >
parse            returns: $# relay $@ <IP> $: isaac < @ linux . org . au >
```

What Did I do wrong? I rebooted my server allready.
Do I have to install sendmail for example from the ports or is it enough to use the systems sendmail? I just set up my box with minimal and the ports. I didn't install anything addition for sending emails. Just an Appache, PHP, â€¦

Thanks for your help.

Best Regards,
Daniel


----------



## lbol (Nov 18, 2010)

It looks like you have some issues with your DNS name resolution. The 
	
	



```
stat=Host unknown
```
 messages in your maillog file should not be there


----------



## fuhdan (Nov 18, 2010)

Yes I agree. But the Server shouldn't resolve any IP. In production, there will be no DNS server available. Thats why I put the IP in the config, for the relay host. I tried to ad the FQDN for the relay host and add it to the hosts file. I got the same issue.
Somehow the mail flow doesn't seem to be the same, when I use the [cmd=]sendmail -f[/cmd] command and when I use the the [cmd=]sendmail -bt[/cmd] And I don't know why. It looks ok, when I use the [cmd=]sendmail -bt[/cmd] command.
Any Ideas?


----------



## lbol (Nov 18, 2010)

as far as I know sendmail uses DNS extensivly. I doubt that you can tell sendmail not to do DNS requests


----------



## DutchDaemon (Nov 18, 2010)

fuhdan, use the proper formatting tags when posting system output, log files, etc.


----------



## lbol (Nov 18, 2010)

you may try to put the IP address of the smart host into angle brackets in your sendmail.cf file


----------



## DutchDaemon (Nov 18, 2010)

You need to use square brackets to prevent any DNS lookups, something like:


```
DS[111.222.111.222]
```

should work.

Of course you should do this by changing the relevant .mc file and generating the new .cf file, not by editing the .cf file.


----------



## fuhdan (Nov 19, 2010)

Hi DutchDaemon
I will use the proper formatting next time.
That did it. It works fine now. Thanks


----------

