Fix the logic of purge mail queue.