11

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?

2
  • 2
    How does the mailq output look? Have you examined an email header already? If not, have a look for possible sender ip, email, server etc, you can also post it.
    – Diamond
    Nov 20, 2015 at 19:17
  • 1
    Thank you, i was unaware of mailq so I googled it and found that doing postsuper -d ALLwould delete them all. It seems it deleted 5615 messages... (source: cyberciti.biz/tips/howto-postfix-flush-mail-queue.html)
    – pixeline
    Nov 20, 2015 at 19:29

2 Answers 2

20

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.
4

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

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .