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?
Best Answer
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 andpostsuper -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
orpostqueue -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 likemailq | more
.postfix flush
orpostfix -f
which try to flush the queue or in other words try to send them immediately.postsuper -d ALL deferred
.qshape
is also a very useful command while examining mailq. Please check Postfix Bottleneck Analysis.