Does postfix restart delete mails

A great question about Postfix!

By default, Postfix does not delete emails when it restarts. When Postfix restarts, it will continue to process any pending emails in its queue, but it will not delete any emails that were already stored in the queue.

However, there are a few scenarios where Postfix might delete emails when it restarts:

  1. Queue cleanup: Postfix has a built-in queue cleanup process that runs periodically (by default, every 30 minutes). During this process, Postfix checks the queue for emails that are older than a certain age (by default, 2 weeks) and deletes them. If Postfix restarts, it will continue this cleanup process, which might result in the deletion of older emails.
  2. Queue expiration: Postfix also has a queue expiration mechanism that allows you to specify a maximum age for emails in the queue. If an email exceeds this age, it will be deleted. If Postfix restarts, it will check the queue for emails that have exceeded this age and delete them.
  3. Configuration settings: You can configure Postfix to delete emails when it restarts by setting the queue_min_free_space parameter in the main.cf file. This parameter specifies the minimum amount of free disk space required in the queue directory. If the queue directory runs out of space, Postfix will delete emails to free up space. If Postfix restarts, it will check the queue directory for available space and delete emails if necessary.

To summarize, Postfix does not delete emails by default when it restarts. However, it may delete emails during queue cleanup, queue expiration, or if the queue directory runs out of space.