Sendmail is only accepting connections from localhost (127.0.0.1 IP)

Q. My sendmail service is running under Linux and whenever I try to telnet it from other LAN IP, it gives connection refuse error. If I connect it from localhost it accept connection. I can only send mail from my server only. How do I force sendmail to accept mail from other hosts/LAN ips?

ADVERTISEMENTS

A. For security reason sendmail is by default configured to accept connection from local system (127.0.0.1). This should avoid open mail relay problem.

To allow connections from ALL hosts/LAN IPs open sendmail.mc file (login as the root):

# vi /etc/mail/sendmail.mc

Look for line that read as follows:

DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA’)dnl

Comment or remove above line and insert new line that read as follows:

DAEMON_OPTIONS(`Port=smtp,Name=MTA’)dnl

Above line will force to accept connection from any host. Save the file. Regenerate sendmail configuration file using m4:

# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

Restart sendmail service :

# /etc/init.d/sendmail restart

Caution: You should configure firewall and other Sendmail Anti-Spam configuration control to avoid problems.

See also:

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source & DevOps topics via:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
5 comments… add one
  • Moeed Oct 9, 2006 @ 3:50

    THanks!!! I was about to pull my hair out thinking it was my host. Such a simple fix.

  • Trent Aug 17, 2008 @ 21:11

    That does not work. Sendmail still does not allow incoming connections, however it is now sending out mail.

  • juraj Oct 29, 2008 @ 19:54

    Hello, this solution doesn’t work for me either, i tried even to specify to run the daemon on specific address but it still binds to localhost =(

  • Trent Oct 30, 2008 @ 3:45

    I gave up and just started using gmail for organizations. You can access via POP/SMTP or web.

    Best of all it’s free

  • tom Feb 14, 2012 @ 11:27

    nice!! helped me a lot…
    thnx for posting!

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.