A Go tool for analyzing Postfix email server bounce logs and generating reports in JSON and Excel formats.
This utility scans Postfix mail server logs to identify email bounces, extracts relevant information, and outputs structured data in both JSON and Excel formats. It's useful for email administrators who need to analyze and report on email delivery failures.
- Scans Postfix log files for bounce information
- Extracts details such as sender, recipient, bounce reason, and DSN codes
- Classifies bounces (hard vs soft)
- Outputs data in JSON format for programmatic use
- Generates Excel spreadsheets for easy analysis and reporting
- Supports scanning directories recursively
- Go 1.21+
- Postfix mail server logs
- Environment variable setup in
.envfile
git clone https://github.com/agldw/postfix-bounce-parser.git
cd postfix-bounce-parser
go mod tidyCreate a .env file in the project root with the following:
LOG_DIR=/path/to/your/postfix/logs
Simply run the binary:
go run main.goThe tool will:
- Scan all files in the directory specified by
LOG_DIR(including subdirectories) - For each file containing bounce information:
- Create a JSON file with the same name plus
.jsonextension - Create an Excel file with the same name plus
.xlsxextension
- Create a JSON file with the same name plus
Each bounce record contains:
date: Timestamp of the bounce eventqueueId: Postfix queue IDfrom: Sender email addressto: Recipient email addressrelay: Server that reported the bouncedelay: Delivery delay timedelays: Breakdown of delay componentsdsn: Delivery Status Notification codestatus: Delivery statusreason: Human-readable bounce reason
Excel files contain the same data in spreadsheet format with the following columns:
- Date
- From
- To
- Relay
- Delay
- DSN
- Status
- Reason
MIT
Contributions welcome! Please feel free to submit a Pull Request.