How can I change how long undeliverable messages stay in the queue?

By default, a message that is not deliverable will stay in the Postfix queue for 5 days with the sender not being notfied at all during this time.

Such a setting may have been useful in the days the internet wasn’t as reliable as it is today, but hardly makes sense anymore.

To change this, edit

/etc/postfix/main.cf

and add or alter the following parameters:

maximal_queue_lifetime = 2d
delay_warning_time = 6h

This will reduce the maximum time a message stays in the queue to 2 days, while at the same time, notifying the sender of the delay after 6 hours.

When done issue:

sudo postfix reload