# sendmail/postfix local mail delivery problem



## sand_man (Dec 13, 2010)

Hi everyone.
I have a dovecot/postfix mail server setup in a jail. Everything works as it should. I can connect, send and receive both from the LAN and WAN. I can also telnet to both ports 25 and 465(for TLS) on both LAN and WAN.
The problem I am having is when sendmail sends mail to a local account. If postfix delivers it, it's fine but if say I have a system message sent to root I get connection refused. I noticed this problem when trying to set up spamd (spamassassin). After the message is passed to spamd to process it, it uses sendmail to deliver the message to the final destination.

See below a couple of system messages.

```
root@sarah-jane /root > mailq
                /var/spool/mqueue (2 requests)
-----Q-ID----- --Size-- -----Q-Time----- ------------Sender/Recipient-----------
oBCGWYbY094773     1115 Mon Dec 13 03:02 root
                 (Deferred: Connection refused by my.domain.com.)
                                         admin@my.domain.com\011
oBCGWYKd094763     2205 Mon Dec 13 03:02 root
                 (Deferred: Connection refused by my.domain.com.)
                                         admin@my.domain.com\011
                Total requests: 2
```

I spent a long time trying to figure this out and now that I think about it, I think it is a routing issue. I do not run a DNS server so my.domain.com should be the local machine which is 192.168.1.90 but my guess is that it is trying to connect to port 25 on my gateway/router. I have my.domain.com in the /etc/hosts file as the jail's IP address and as I said before, I can telnet through that domain locally it's only sendmail that has the problem.

my.domain.com is not my real domain obviously 
Does anyone know what I can do to troubleshoot this further? It is driving me mad.

Edit:

OK now I'm certain that is the problem. Turns out I can't telnet to port 25 from WAN so I guess it is trying to connect through my router instead of just delivering locally. I'm still at a loss to how I make sendmail deliver to the machine it's on instead of going the long way around...


----------



## DutchDaemon (Dec 13, 2010)

Is something handling *local* mail, i.e. email addressed to *127.0.0.1:25*?


----------



## sand_man (Dec 14, 2010)

I am not very experienced in this field but I just thought that postfix would handle local mail. What am I meant to use?


----------



## DutchDaemon (Dec 14, 2010)

Local email (which in this case means: system email) is handled (in the base install) by Sendmail (running on localhost only).

It should show up as 
	
	



```
$ sockstat -l4p25
USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS      
root     sendmail   1179  4  tcp4   127.0.0.1:25          *:*
```

It will deliver that mail to a local mailbox, or if you specified an alias mapped to an external address, it will send the mail to that address.

You can make Postfix do the same thing, I'm sure, or change 
	
	



```
sendmail_enable="NONE"
```
 into 
	
	



```
sendmail_enable="NO"
```
 in /etc/rc.conf.


----------



## sand_man (Dec 24, 2010)

Well this is a jail that I built quite some time ago. It's possible I didn't build sendmail (I can't remember) but there is a sendmail executable which I thought belonged to postfix.


```
root@sarah-jane / > sockstat -l4p25
USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS      
root     master     1546  16 tcp4   192.168.1.90:25       *:*
```

master, I assume is postfix. So why won't it accept system mail?


Relevant part of /etc/rc.conf

```
postfix_enable="YES"
sendmail_enable="NO"
sendmail_flags="-bd"
sendmail_pidfile="/var/spool/postfix/pid/master.pid"
sendmail_procname="/usr/local/libexec/postfix/master"
sendmail_outbound_enable="NO"
sendmail_submit_enable="NO"
sendmail_msp_queue_enable="NO"
```


----------



## sand_man (Dec 24, 2010)

I'm sorry, I think it's a problem with the way my aliases are set up.
I'll see if I can have the system messages sent to the host instead of the local jail.
Thanks for you help.


----------

