Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Create an online spam trap counter' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Create an online spam trap counter
Authored by: iordonez on Jan 13, '04 03:48:39PM

Now the great question would be... How can this be done using spamassassin, amavis and Postfix on a server? I'd love to be able to add a counter on my webmail page that shows our users just how many messages we have trapped that are spam. I can't find anywhere for either to run a script when mail is received and considered spam. Anyone got any great ideas out there?



[ Reply to This | # ]
Create an online spam trap counter
Authored by: wsdr on Jan 14, '04 10:06:29AM
iordonez, I use the Exim mail server instead of Postfix, so I don't know if this directly relates. But Exim has a conf file that you have to edit to have Exim call Spamassassin. In my instance we use a MySQL database to store email accout info, and so Exim is also making calls to that. In the rule that Exim uses to decide if an email is spam, I added another call to MySQL that increments a column by one (if it's spam). It looks like this:
deny message = Spam score too high ($spam_score)
     condition = ${if >{$acl_m1}{0}{1}{0}}
     condition = ${if {$spam_score_int}{$acl_m1}{1}{0}}
     set acl_m3 = ${lookup mysql{UPDATE spam set spamcount=spamcount+1}}
The last line is the relevant one; this statement appears in the acl_check_content section of the config file. If you're using Exim, don't copy my code verbatim because much of it relates to our customizations of Exim and Spamassassin-- you're on your own there. If you want to set up Exim & Spamassassin, visit afp548.com for articles on this (not affiliated, just found their articles very helpful).

To do this I had to add a new table to the MySQL email user database, but it's a table with only one column. I guess I could write to text file, but this was easier to do.

[ Reply to This | # ]