Postfix
Postfix has the following relevant queues:
- Active: Email that is going to be delivered
- Deferred: Email that failed to be delivered, but is being retried until delivery succeeds.
- Hold: Email that was place on hold is not automatically retried.
Inspecting mail queues
The following will generate an overview of mails in the queues, grouped by sender:
kolabctl postfix mailq-count-senders
To get a quick count:
kolabctl postfix find /var/spool/postfix/deferred/ -type f -print | wc -l
Putting mails on hold by sender address
The following will move mails from a specific sender, that are currently in the active or deferred queue, to the hold queue.
kolabctl postfix mailq-put-on-hold $sender
To delete emails that are currently in the hold queue, by sender:
kolabctl postfix mailq-purge-hold-queue --from $sender --now
Print queued emails
Print all queued emails, from all queues.
kolabctl postfix postqueue -p
Delete emails from all queues by sender
To delete emails that are currently in any queue, by sender:
kolabctl postfix bash -c "postqueue -p | grep $sender | grep -oE '^[0-9A-F]*' | postsuper -d -"
Delete emails from hold queue by age
To delete emails that are currently in the hold queue (older than 50 days in this example):
kolabctl postfix bash -c "find /var/spool/postfix/hold -type f -mtime +50 -printf '%f\n' | sed 's/[*!]\$//' | postsuper -d -"
Delete all emails in a queue
To delete all emails that are currently in a queue:
postsuper -d ALL hold
Release emails from the hold queue
To release all emails in the hold queue:
kolabctl postfix postsuper -H ALL
Print a message by id
kolabctl postfix postcat -q $messageid
Note
Exclude the the queue indicator from the message id, so strip the '!' from a message in the hold queue.
Process the mailqueue immediately
kolabctl postfix postqueue -f