You are here: Home > Projects > Procmail Log to SQLite Database
Pmlog2db will extract useful information from a Procmail log file and add it to an existing SQLite database, where it can be processed in a meriod of wonderful ways all involving SQL.
This script processes log files from Procmail, which have entries
similar to the following.
From wrivera_ip@tip.com.pl Wed May 26 12:30:49 2004
Subject: Pharmacy with smart prices
Folder: /net/u/1/c/ccn/Mail/spam/sa 4290
This entry contains information for a single message, including the
originating email address, date of receipt, subject, folder where the
message was placed, and size in bytes. The script expects each series of
three lines to be information for a single message, and that the log
file to be processed will contain no extraneous lines.
The script expects one command-line argument, which is the name of a Procmail log file. It expects a SQLite database named msgs.db to be in the current directory. Provided that these conditions are met, the log file is processed.
The database is composed of only one table. The database and table can be created with a command similar to the following.
sqlite msgs.db 'create table msg(addr, mon, day, hour, min, sec,
year, sub, folder, size);'
The fields in table msgs have these meanings:
This script is available as pmlog2db.pl, and is made available under the BSD license.
Given the amount of data retained about each message, and the pouwer of SQL, it is possible to ask questions such as:
I hope this script is useful in some way. Feel free to send a message if you find it useful or have a comment.