A default installation of sendmail usually yields a configuration where sendmail will only accept email from email clients on the server on which sendmail is running. Usually, you will want to allow external email servers to send email to valid email addresses on the server. To do so, edit
/etc/mail/sendmail.mc
. Comment out the following line by putting
dnl
at the beginning of the line:
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
The line should then appear as follows:
dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
You then need to rebuild the /etc/mail/sendmail.cf
file
from the /etc/mail/sendmail.mc
file using the m4
command as shown below:
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
Once you've rebuilt the sendmail.cf
file, you need to restart
sendmail. You may be able to restart sendmail with a
/etc/init.d/sendmail restart
command, though on some Linux
systems, e.g., CentOS 7, you will see a No such file or directory
error message, if you try that command. On a CentOS 7 system, you can
restart sendmail with systemctl restart sendmail
.
# /etc/init.d/sendmail restart -bash: /etc/init.d/sendmail: No such file or directory # systemctl restart sendmail #
Or you can also use service sendmail restart
on a CentOS 7
system to restart sendmail.
# service sendmail restart Redirecting to /bin/systemctl restart sendmail.service #
Once you've restarted sendmail, external servers sending email to domain names present in the local-host-names file, should no longer receive "relaying denied" error messages in bounced email. They still would not be able to send email to email addresses for domain names not in that file. I.e., the server won't function as an "open mail relay".