Clearing the mail queue in FreeBSD 14.0 (and newer, probably)

tags: unix FreeBSD

I have my FreeBSD machine set up to email me status reports in cron jobs. These seem to sometimes fail to deliver for reasons I don't understand.

If you search the web for this, you will find tips about how to do this for sendmail. If you are like me you configured your email when you installed the system and didn't touch it after that, which means that you of course don't remember which mail server you run, and more importantly have forgotten that the default one is DMA, not sendmail.

This is made slightly worse by the fact that standard commands to view the queue like mailq will work and show your queue, but when you look in /var/spool/mqueue it will be empty. However, there is a /var/spool/dma that works exactly the same. Delete the files in there and you've cleaned your queue!

(If I ever get around to adding a periodic task to delete those emails I'll add it here, but for now I'll just do the manual janitorial work that computers were supposed to liberate us from).