www/content/blog/miscellaneous/purge-postfix-queue-based-content.md

19 lines
546 B
Markdown
Raw Permalink Normal View History

2020-04-28 17:29:52 +02:00
---
title: "Purge postfix queue based on email contents"
date: 2009-04-27
2021-03-12 18:12:41 +01:00
description: How to selectively purge a postfix queue based on email contents
tags:
- toolbox
2020-04-28 17:29:52 +02:00
---
2021-03-12 18:12:41 +01:00
## The problem
2020-04-28 17:29:52 +02:00
2021-03-12 18:12:41 +01:00
Sometimes a lot of spam can acacumulate in a postfix queue.
## The solution
Here is a command that can search through queued emails for a certain character string (here XXX as an example) and delete the ones that contain it :
```sh
2020-04-28 17:29:52 +02:00
find /var/spool/postfix/deferred/ -type f -exec grep -li 'XXX' '{}' \; | xargs -n1 basename | xargs -n1 postsuper -d
```