Knowledge base

acctfind

Search through accounting files
Find a specific message

Searches accounting files for records by field values and prints the selected fields of the found records — as standard output, CSV, TSV, HTML, XML, “pretty” XML or a custom format.

On Unix the program is called pmtaacctfind and lives in /usr/sbin; on Windows it is acctfind in the program directory.

Filtering is by record types and by fields. –delivered, –bounced, –status and –mta select record types; without them the search covers deliveries and bounces. –match compares a field with a Perl regular expression or with a case-insensitive string, and short options like –to and –dsnStatus do the same for one field.

It answers the question “what happened to the message to such-and-such recipient” without exporting all of accounting. It does not work with JSON accounting — only with CSV.

The main trap is searching in the wrong file. Accounting rotates, and a message is “not found” more often because the search was in today’s file while the message stayed in a rotated one. Several files can be named at once.
What the Hub does. It does not call it: accounting events reach the Hub as a stream through the webhook, and it computes the “Accounting stats” summaries on the node with another program — pmtastats.
Recommended values

When to use it:

Question This command or not
what happened to a message to one recipient yes — –to
who bounced with a permanent error yes — –bounced –dsnStatus m/^5\./
a summary of deliveries and bounces no — pmtastats
what is in the queue now no — list
The program name on Unix, record types, –match, output formats and the fact that JSON accounting is not supported come from the manual (§ 12.5). The split of questions is ours.
Example configuration
# what happened to messages to one recipient: outcome, queue time and delivery time
pmtaacctfind --iso-times --to test@example.com --output tsv[to,dsnAction,timeQueued,timeDelivered] /var/log/pmta/acct-*.csv
The manual’s example with a different address: tsv[…] sets the order of fields in the output line.
yellow — — directive names, blue — blocks. They are highlighted the same way in the text of the card.
Compatibility
PowerMTA 6.0
described in the manual of this version · platform: any
The vendor does not state the first version for every directive — there is no note here. The name also appears in the 5.0 edition of the manual.
How to check on the node
Check that the needed accounting files are in place:
ls -l /var/log/pmta/acct*
head -1 "$(ls -t /var/log/pmta/acct-*.csv | head -1)"
The first CSV line is the field names: these are what –output and –match refer to.
In the Hub
Cost of a mistake
safe: a wrong value breaks nothing
Scenarios
Troubleshoot deliverability