Skip to content

Instantly share code, notes, and snippets.

@flickerfly
Last active November 14, 2016 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flickerfly/1414a69d3a51c739048b0aeb031390ab to your computer and use it in GitHub Desktop.
Save flickerfly/1414a69d3a51c739048b0aeb031390ab to your computer and use it in GitHub Desktop.
Show the PHP scripts sending email currently in the queue of a postfix server
#!/bin/bash
# This works only if postfix is running. It is complete, but when dealing with large queues due to spam loads,etc., it can take a long time
#mailq |cut -f 1 -d " "|egrep -v "^\(|^$|^-|\*" |xargs postcat -q |grep "X-PHP-Originating-Script"|sort|uniq
# This will work when postfix is not running. It may run faster, but it may also get stuck due to long argument lists.
postcat /var/spool/postfix/maildrop/* |grep "X-PHP-Originating-Script"|sort|uniq
postcat /var/spool/postfix/*/* |grep "X-PHP-Originating-Script"|sort|uniq
postcat /var/spool/postfix/*/*/* |grep "X-PHP-Originating-Script"|sort|uniq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment