$self->log(LOGDEBUG,"data_post body log statement:".$statement);
$dbh->do($statement)
|| $self->log(LOGERROR,$dbh->errstr());
}#end body log
return(DECLINED);
}
sub disconnect_handler
{my($self,$transaction) = @_;
$dbh->disconnect();
return(DECLINED);
}
=head1 NAME
log2sql - qmstpd plugin for logging information for mail messages in a SQL database.
=head1 DESCRIPTION
The plugin logs the information for mail messages: remote_ip, remote_host, remote_info,
sender, subject, header_size, body_size, spam_status (this is the 'hits' field from spamassassin 'X-Spam-Status' header line), header ,all recipients of the message, etc. The data is logged into two tables: messages table - one message per row,
recipients table - one recipient per row. One message could have more than one recipient.
=head1 CONFIGURATION
The plugin accepts the following parameters:
t - type of the SQL database (mysql, postgresql, etc.)
d - database name (default qpsmtpd)
h - hostname of the database server (optional)
P - tcp port of the database server (optional)
o - dsn options (in format like DBI dsn options). For example: "o mysql_socket=/path/to/socket"
m - database table for mail messages (default messages)
r - database table for the recipients (default rcpts)
u - database user (default root)
p - database password (default '')
H - log the header of the message in the main table for mail messages (e.g. 'messages'). For example "H Yes".
=head1 CONFIGURATION OF THE ADDITIONAL FEATURES
You can configure the following additional features:
D - log the deny information for denied messages in the 'messages' table. Example "D Yes". The 'deny' hook must be enabled in order to use this feature.
B - log the body of all messages in the separated table (e.g. 'message_body'). Example "B Yes".
DB - log the body of the denied messages. D parameter required. Example "DB Yes".
b - sql table for the message bodies. Default: 'message_body'.
As default the plugin sets a note 'log2sql_mail_id'. This chunk of data is passed to other plugins. As default the plugin sets a field 'X-Sql-Log-ID' in the message header.
=head1 SQL TABLES
Here are the CREATE statements for the tables. Assuming the 'messages' table is the table for logging main information for messages, 'rcpts' table is the table for recipients, 'message_body' is optional table if You want to log messages bodies (of the denied messages OR of all messages). This syntax is MySQL syntax. For other databases the syntax could be slightly different.