Postfix Spamming Check

We can use different commands to check the mail activities on a postfix mail server. Some examples provided below:

1. To check the mail queue:

# mailq

To get the number of mails in the queue:
# mailq | wc -l


2. To flush the mail queue:

# postfix -f
# postfix flush  OR

3. To remove all mails from the queue:

# postsuper -d ALL

4. To remove all mails in the deferred queue:

# postsuper -d ALL deferred

5. To know the number of messages there in the deferred queue:

# find /var/spool/postfix/deferred -type f | wc -l

6. To get a sorted list of the accounts that have the most mail in the queue. This usually means a maximum of 2 or 3 spammers at the end of the list:

# mailq|grep ^[A-F0-9]|cut -c 42-80|sort |uniq -c|sort -n|tail

7. Check which script is sending spam:

postcat -q <ID>
You can get the message ID from mailq command.

Usually, it will show the script which contains "X-PHP-Originating-Script". Check and identify the line which starts with "X-PHP-Originating-Script" and you can remove the script file as well since it will show the path as well. 


  • postfix spamming
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How To Install and Use Docker on Ubuntu 16.04

Introduction Docker is an application that makes it simple and easy to run application processes...

Change Main IP of the server :: Vesta Panel

If we are changing the main IP of a server installed with Vesta panel, we can use the following...

cPanel: Apache-FastCGI Data Timeout Error

If you are using a cPanel server and have FastCGI enabled in Apache, you might be facing the...

Domainkey installer in cPanel

You can use the following cPanel script to install domainkey for an account...

Email issues :: Common Troubleshooting Steps

Here I will discuss some common errors and their solution: We are using a mail relay setup for...