LinuxWorld

Getting Sendmail to listen to local requests

I want to configure a Linux Sendmail server to deliver mail from localhost to support sending e-mail from a Web application on the same machine. The Sendmail service will deliver mail from remote systems, but mail originating on the local system results in a mail log message that ends with 'dsn 4.0.0. Status: deferred, connection refused'. I added localhost to the 'local-host-names' file in the /etc/mail folder and restarted Sendmail but still get the error message for local mail.

It sounds like Sendmail is ignoring connection requests on the localhost address 127.0.0.1. This is the default behavior in newer versions of Sendmail and is meant to make it more difficult for spammers to relay spoofed e-mail through your mail server.

Enabling local mail delivery can be made safer by adjusting your firewall to allow only localhost to accept connections to Port 25 from localhost itself. To enable Sendmail connections to localhost from localhost, add the localhost address 127.0.0.1 to the DaemonPortOptions setting in the Sendmail configuration file.

Make the changes to the /etc/mail/sendmail.mc file, then regenerate the sendmail.cf file and restart Sendmail. Many Linux systems rebuild sendmail.cf every time /etc/init.d/sendmail is used to start Sendmail, so making the change may be as simple as adding the line "DAEMON_OPTIONS('Port=smtp,Addr=127.0.0.1, Name=MTA')dnl" below the existing DAEMON_OPTIONS line in sendmail.mc and issuing the command /etc/init.d/sendmail restart.

React: Give us your thoughts on the issues here.
Use this form to start a public discussion with other Linux World users on this article.
Log In | Register for an account (Why you should)

Note: Register to have your user name appear; otherwise your comment will show up as "Anonymous."

*Anonymous comments will only appear once they are approved by the moderator.

Newsletter sign-up

Sign up for one of Network World's newsletters compliments of Linux World

Linux & Open Source News Alert
Web Applications Alert
Video & Podcast Alert
Security: Threat  Alert
Virtualization Alert

Email Address: