Ubuntu – SendMail: Connection refused by [127.0.0.1]

dovecotsendmailUbuntu

So I've installed Sendmail service, Dovecot and SquirrelMail in my server. I arrived to receive mails from local clients (different hosts in the same newtork). But I cannot send mails from server to clients, and also when a client host try to send mail to another client of this server ,the server recieve it but it cannot relay it to the other client. (NB: I'm working only in a local network). This is the error from my mail.log:

Nov 30 15:34:10 dev sendmail[5620]: uAUFY8Jl005620: from=dev, size=4, class=0, nrcpts=1, msgid=<201611301534.uAUFY8Jl005620@dev.localhost>, relay=root@localhost
Nov 30 15:34:10 dev sendmail[5620]: uAUFY8Jl005620: to=FatimaZ@test.test2.fr, ctladdr=dev (1000/1000), delay=00:00:02, xdelay=00:00:00, mailer=relay, pri=30004, relay=[127.0.0.1] [127.0.0.1], dsn=4.0.0, stat=Deferred: Connection refused by [127.0.0.1]
Nov 30 15:40:01 dev sm-msp-queue[5802]: uAUFQnYE005516: to=FatimaZ@test.test2.fr, ctladdr=dev (1000/1000), delay=00:13:12,

And whene client1 try to send to client2 , I get this error

Nov 30 15:57:52 dev sm-mta[5853]: uAUFvQin005853: client1@test.test2.fr … User unknown
Nov 30 15:57:57 dev sm-mta[5853]: uAUFvQin005853: from=client1@test.test2.fr, size=0, class=0, nrcpts=0, proto=SMTP, daemon=MTA, relay=client2.test.test2.fr [192.168.0.3]

This is how my /etc/hosts file looks like:

 127.0.0.1       dev.localhost dev
 127.0.1.1       dev   
 192.168.0.1     dnsServer1.test.test2.fr dnsServer1 
 192.168.0.1     mail.test.test2.fr       mail

And the /etc/mail/local-host-names :

localhost
192.168.0.1
mail.test.test2.fr
test.test2.fr
dev

I'm in ubuntu 14. Thank you for your help.

Extra info from comments:

$netstat -ant | grep :25 
tcp 0 0 192.168.0.1:25 0.0.0.0:* LISTEN 
tcp6 0 0 ::1:25 :::* LISTEN

Best Answer

Sendmail passes messages submitted by "send via command line sendmail" to local sendmail daemon listening at 127.0.0.1:25.

It seems that you sendmail listens only on IPv4 192.168.0.1:25 (local network?) and IPv6 ::1:25 (any). Most likely you wanted to accept incoming TCP connections only from local network.

Fix DAEMON_OPTIONS in your sendmail.mc file. Add listening on 127.0.0.1 or use listening on IPv4 "any".


In your sendmail.mc add the second DAEMON_OPTIONS listed below.
Recompile sendmail.mc into sendmail.cf and restart (or HUP) sendmail daemon.

DAEMON_OPTIONS(`Port=smtp, Addr=192.168.0.1, Name=MTA')dnl
DAEMON_OPTIONS(`Port=smtp, Addr=127.0.0.1, Name=MTA-loopback')dnl
Related Topic