NAME

postqgrep - Postfix message queue display and filtering utility

SYNOPSIS

postqgrep [-h] [-V] [-i|-c] [-a|-z] [-R] [-I] [-f <sender>] [-r <recipient>] [-y <timeframe>] [-o <timeframe>] [-A <datetime>] [-B <datetime>]

 Options:
    -h --help                     Display detailed help message
    -V --version                  Display version information
    -i --id                       Only display postfix queue IDs
    -c --count                    Only display count of matching mails
    -a --active                   Mails in the active queue only
    -z --hold                     Mails in the hold queue only
    -R --regex                    Treat <sender> and <recipient> as regular expressions
    -I --insensitive              Make --from and --recipient check non-case sensitive
    -f --from        <sender>     Match e-mails from <sender>
    -r --recipient   <recipient>  Match e-mails to <recipient>
    -y --younger     <timeframe>  Match items in queue for less than <timeframe>
    -o --older       <timeframe>  Match items in queue for more than <timeframe>
    -A --after       <datetime>   Match items in queue since after <datetime>
    -B --before      <datetime>   Match items in queue since before <datetime>

OPTIONS

-h --help

Print a brief help message and exit.

-V --version

Print version number and exit.

-i --id

Only display queue IDs. Useful for piping output to another command such as postsuper.

-c --count

Only display total number of mails which matched paramters.

-a --active

Only display mails in the active queue. Cannot be combined with option -z.

-z --hold

Only display mails in the hold queue. Cannot be combined with option -a.

-f --from <sender>

Filter mails from <sender>. Can be specified as a complete address or a domain name. Note that this is case sensitive.

-r --recipient <recipient>

Filter mails to <recipient>. Can be specified as a complete address or a domain name. Note that this is case sensitive.

-R --regex

Treat <sender> and <recipient> as Perl regular expressions. This overrides the default behaviour of treating <sender> and <recipient> as e-mail addresses/domains.

-y --younger <timeframe>

Match items in queue for less than <timeframe>. timeframe should be comprised of numbers followed by units. E.g. 10m5s or '10 mins 5 secs'

-o --older <timeframe>

Match items in queue for more than <timeframe>. timeframe should be comprised of numbers followed by units. If a single number with no unit is specific then it is assumed to be seconds. E.g. 10m5s or '10 mins 5 secs'

-A --after <datetime>

Match items in queue since after <datetime>. datetime should be expressed as a string whose format will be guessed. If only a date and no time is specified, then the time is assumed to be midnight E.g. -A '2015-05-20' is the same as -A '2015-05-20 00:00:00'

-B --before <datetime>

Match items in queue since before <datetime>. datetme should be expressed as a string whose format will be guessed. If only a date and no time is specified, then the time is assumed to be midnight E.g. -B '2015-05-20' is the same as -B '2015-05-20 00:00:00'

DESCRIPTION

This command reads the contents of the Postfix mail queue (using the command postqueue) and filters according to arguments provided. It is loosely based on the command exiqgrep which provides similar functionality for the exim mail server.

EXAMPLES

postqgrep -i -f somedomain.com -o '10 hours 5m' -A '2015-05-01 08:00:00'

Display only Postfix queue IDs for mails sent from *@somedomain.com which have been queued for more than 10 hours and 5 minutes, and arrived in the queue after 8AM local time on 1st May 2015.

postqgrep -z --to someuser@anotherdomain.com

Display full information for mails in the hold queue which are from someuser@anotherdomain.com

postqgrep --count --regex --from '^postmaster@'

Display the number of mails which are from postmaster@*

CAVEATS

To display mails from e-mail addresses with no domain (e.g. MAILER-DAEMON) it is necessary to use a regular expression since specifying MAILER-DAMON as the value of --from or --to will be treated as a domain search (i.e. *@MAILER-DAEMON) which will not work as expected. An example regular expression would be '^MAILDER-DAEMON$'

The options --before and --after use the perl module Date::Parse to guess the format used and will assume the US format mm/dd/yyyy rather than dd/mm/yyyy. It is recommended to use ISO 8601 date format to prevent confusion i.e. yyyy-mm-dd

The options --younger and --older accept the following units: m min mins minute minutes s sec secs second seconds h hour hours d day days

COPYRIGHT

2015 Jim Scadden <jims at silentasylum.co.uk>

LICENSE

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

SEE ALSO

postqueue(1)