public class AddressKind implements Serializable
{
public static final AddressKind FROM = new AddressKind('F', "FROM");
public static final AddressKind TO = new AddressKind('T', "TO");
public static final AddressKind CC = new AddressKind('C', "CC");
// These only apply to SMTP:
public static final AddressKind ENVELOPE_FROM = new AddressKind('G', "ENVELOPE_FROM");
public static final AddressKind ENVELOPE_TO = new AddressKind('B', "ENVELOPE_TO");
// These only apply to IMAP/POP3:
public static final AddressKind USER = new AddressKind('U', "USER");
The following sql query should get what we wanted:
SELECT
m.time_stamp,
a2.addr as sender,
a1.addr as recipient,
m.subject,
sa.score,
sa.is_spam,
sa.action,
ep.c_client_addr as sender_ip,
a1.msg_id
FROM
events.n_mail_message_info_addr a1,
events.n_mail_message_info_addr a2,
events.n_mail_message_info m,
events.n_spam_evt_smtp sa, /* use n_spam_evt for pop and imap event */
events.pl_endp ep
WHERE
a1.msg_id = a2.msg_id and
a2.kind = 'G' and /* use 'F' for pop and imap */
a1.kind = 'B' and /* use 'T' or 'C' for pop and imap */
a1.msg_id = m.id and
m.id = sa.msg_id and
m.pl_endp_id = ep.event_id and
m.time_stamp >= (date 'today')
===== Admin Interface =====
The next task is to build a admin interface. It should allow filter on these criteria:
* Start/End date
* Sender Address
* Recipient Address
I decided to use perl to build it. These packages are needed:
* [[http://packages.debian.org/lenny/i386/libpq-dev/download|libpq-dev]]
* [[http://packages.debian.org/lenny/i386/libc6-dev/download|libc6-dev]]
* [[http://packages.debian.org/lenny/i386/linux-libc-dev/download|linux-libc-dev]]
Install the perl ''DBD::Pg'' module.
Enable ''cgi-bin'' script folder by creating file ''/etc/apache2/conf.d/cgi-bin.conf'':
\n";
print "time_stamp | sender | rcpt | subject | score | action ", "\n";
# TO-DO: use a template to beautify the output, may be use a table
# loop print all rows:
while ($qrow = $q->fetchrow_hashref) {
$time_stamp = $qrow->{time_stamp};
$sender = $qrow->{sender};
$rcpt = $qrow->{rcpt};
$subject = $qrow->{subject};
$score = $qrow->{score};
$action = $qrow->{action};
print $time_stamp, ' | ', $sender, ' | ', $rcpt, ' | ', $subject, ' | ', $score, ' | ', $action, "\n";
}
print "\n";
print $w->end_html;