-1

My crontab keeps sending emails to root user email. I have already tried to fix the problem by editing the followings:

In /etc/crontab edited the following:

MAILTO=root

to

MAILTO=email@domain.com

and restarted service by running service crond restart.

But cron results are still sent to root email address and not to the specified email address in crontab.

How can I fix that, any ideas?

Diamond
  • 9,001
  • 3
  • 24
  • 38
Joe M.
  • 1
  • 1
  • what do the logs (/var/log/cron) say? Perhaps there is a certain cronjob that sends mails to the root user email. The log should indicate what job is sending the email. – 030 Dec 01 '15 at 11:01
  • `contab -l`, what does it output? Probably you have crons executing from other configs. Also, you should not need a crond restart. – Florin Asăvoaie Dec 01 '15 at 11:51
  • I call php file which prints out and output texts which should be mailed to my specified email address, but it does not. In log file, I can see that php is called... php -q /path/to/script/cron.php – Joe M. Dec 01 '15 at 11:57

1 Answers1

0

Are you sure your system can send mail outside? Try with the mail command:

echo "Hello, world" | mail email@domain.com

If you receive an e-mail, then check if the /etc/aliases file contains anything that aliases email@domain.com to root.

If you don't receive an e-mail, check in the spam folder. If there's nothing there, check your mailer logs in /var/log/. There will be an error explaining what is happening.

lorenzog
  • 2,799
  • 3
  • 20
  • 24
  • I have tried to send mail to email@domain.com and I do receive the mail without problems. I can also send mails from that mail adresse. no aliases for that mail points to root It used to work before but all of a sudden stopped and keeps sending to root mail – Joe M. Dec 03 '15 at 13:49