crontab sends month-old emails

ubuntu 14.04 Mailserver: Postfix

root receives dozen of emails from crontab. These mails contain PHP warnings.

  • I've fixed the cause for these warnings.
  • I've fixed every cronjobs to not send emails (output sent to >/dev/null 2>&1)
  • I've deleted all previous emails

    /var/mail/root

    /var/spool/mail/root

But I still receive dozen of emails every hour. Those email originate from cronjobs, and are sometimes almost a month old.

I don't understand: where are these emails coming from, and where are they stored?


These are undelivered old mails in email queue. You need to find out and delete them if you want to get rid of them.

You can use mailq to check and postsuper -d ALL to delete them all at once.

Some points to note:

  • Whenever you start recieving relatively old emails, you can be sure that those emails got queued up somewhere (either in the local server or in remote realy) and are now getting delivered.

  • To see the whole queue for postfix, you can use: mailq or postqueue -p and the outputs are same. This can prove ineffective if you have thousands of mails in queue because the commands ouput try to dump all of it at once. In that case, you can use the command like mailq | more.

  • If you have rather necessary mails stuck in queue, you can use: postfix flush or postfix -f which try to flush the queue or in other words try to send them immediately.
  • In a situation where you have lots of deffered emails in the queue and want to remove them exclusively you may use postsuper -d ALL deferred.
  • qshape is also a very useful command while examining mailq. Please check Postfix Bottleneck Analysis.

That sounds like messages that were queued and which are now getting delivered. If those messages originate from your own server they were stored below /var/spool/postfix in the outgoing mail queue and the command sudo showq or sudo postqueue -p should list any remaining undelivered messages still in the queue.

/var/spool/mail/root is a default mailbox location that contains mail that is already delivered to it's final destination, removing messages from there won't prevent any new messages from arriving :)

This Q&A might be of use to clean the queue