Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Our server's /var/ direction keeps filling up due to sendmail sending email to root (the /var/spool/mail/root was 2GB).

All our sites scripts use external smtp servers for sending email so we'd like to disable sendmail on the server to avoid this issue happening again as each time the directory fills up mysql shuts down because it can't write to the /var/log/ directory as it's out of space.

Is there any way to safely shutdown sendmail that won't affect php connecting to external smtp? I'm not sure if sendmail is used for that.

Or perhaps someone knows of a way to disable sendmail from sending email to root no matter what.

share|improve this question
add comment

3 Answers

up vote 1 down vote accepted

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.

share|improve this answer
add comment

Shuting down sendmail may or may not help depending how local mail gets generated. You may still end up with a 2G root mailbox. What you need is to decide whether mail for users on this machine should be sent elsewhere or discarded. You can do so from /etc/mail/aliases which is a "static" solution (because with every new user that gets added to the system you need to add a line in this file too), or a more "dynamic" one, where for example email for local users gets forwarded to a designated user elsewhere:

LOCAL_CONFIG
Kuser user -m -a.FOUND

LOCAL_RULE_0
R$- < $=w . > $*        $: $(user $1 $) < $2 . > $3
R$- . FOUND < $=w . > $*          $@ john.doe < @ example . com . > $3

The above lines are added to sendmail.mc. Next according to your distribution's directives you generate sendmail.cf and restart sendmail. In CentOS this means running /etc/mail/make followed by service sendmail restart.

share|improve this answer
add comment

If running in cron as root just send your MAILTO="" on the first line if your interested in receiving notifications. It is a good suggestion to set it to an email address that will be monitoring the crontab activities.

MAILTO=""
* * * * * /bin/bash script.sh

or to a monitor email address

MAILTO="cronmonitor@company.com"
* * * * * /bin/bash script.sh  
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.