Where are the logs?
The default location depends on your linux/unix system, but the most common places are
- /var/log/maillog
- /var/log/mail.log
- /var/adm/maillog
- /var/adm/syslog/mail.log
If it's not there, look up /etc/syslog.conf
. You should see something like this
mail.* -/var/log/maillog
sendmail writes logs to the mail
facility of syslog. Therefore, which file it gets written to depends on how syslog was configured.
If you system uses syslog-ng (instead of the more "traditional" syslog), then you'll have to look up your syslog-ng.conf
file. You'll should something like this:
# This files are the log come from the mail subsystem.
#
destination mail { file("/var/log/mail.log"); };
destination maillog { file("/var/log/maillog"); };
destination mailinfo { file("/var/log/mail.info"); };
destination mailwarn { file("/var/log/mail.warn"); };
destination mailerr { file("/var/log/mail.err"); };
Unable to send out emails?
One of the most common reason I've seen for a freshly installed sendmail not being able to send out emails is the DAEMON_OPTIONS being set to listen only on 127.0.0.1
See /etc/mail/sendmail.mc
dnl #
dnl # The following causes sendmail to only listen on the IPv4 loopback address
dnl # 127.0.0.1 and not on any other network devices. Remove the loopback
dnl # address restriction to accept email from the internet or intranet.
dnl #
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
If that's your case, remove the "Addr=127.0.0.1" part, rebuild your conf file and you're good to go!
DAEMON_OPTIONS(`Port=smtp, Name=MTA')dnl
[root@server]$ m4 sendmail.mc > /etc/sendmail.cf
[root@server]$/etc/init.d/sendmail restart
If you've been making changes to /etc/sendmail.cf manually thus far (instead of the *.m4 file) you can make similar changes in /etc/sendmail.cf. The offending line will look like this:
O DaemonPortOptions=Port=smtp,Addr=127.0.0.1, Name=MTA
Change it to:
O DaemonPortOptions=Port=smtp, Name=MTA
What I did to disable local delivery. I'll be using the example.com domain.
Requirements:
- example.com A entry pointing to IP address assigned to one of the eth interfaces.
- /etc/hosts defining example.com assigned to the very same IP address as above
- example.com MX records pointing to Google servers (ASPMX.L.GOOGLE.COM, etc)
- default sendmail installation (mine was on Ubuntu)
Steps:
vim /etc/mail/sendmail.mc
at the end:
define(`MAIL_HUB', `example.com.')dnl
define(`LOCAL_RELAY', `example.com.')dnl
and then:
sendmailconfig (or /etc/mail/make depending on your distro)
service sendmail restart
testing:
echo -e "To: user@example.com\nSubject: Test\nTest\n" | sendmail -bm -t -v
echo -e "To: user\nSubject: Test\nTest\n" | sendmail -bm -t -v
You should see it connecting to the google server and then you should see your mail being delivered to your Google inbox.
Best Answer
Your best bet is to simply redirect root's mail via /etc/aliases. Pick another address that can handle the mail volume. Failing that, redirect it to /dev/null. Sendmail can be shutdown and not impact PHP sending mail, assuming that the PHP pages are written to talk to a specific external SMTP server. If they simply send mail without specifying a server to connect to, they end up relaying through localhost, so shutting down sendmail locally would cause the PHP scripts to fail.