mailwatch2rbl should be run periodically at least once per hour and typically every 5 minutes. It will perform the following tasks :-

  1. Erase data from mwrblclients where hour = (current hour +1) mod 24
  2. Store the current data and time in the $curtime variable.
  3. Select all entries in the mailwatch table where time entered >= mwrblconfig.lastrun && time entered <$curtime. For each client ip retrieve the number of mails, number of hams and the number of spams.
  4. Append the data to the mwrblclients table for the current hour.
  5. Update mwrblconfig.lastrun and set it to $curtime.
  6. Erase all the expired data from the mwrblblock table.
  7. Scan through the mwrblclients table and retrieve the sum of each count, and spam entry for each client ip address where ((ham ==0) && (spam>=minspamcount)) and clientip is not already in the block table. Add results to the mwrblblock table with the client ip address, expiry time (current time + blocktime hours), and error description.
    As once a client is blocked there should not be any furthur updates to the mailwatch database I dont think there will ever be a case where you could update the expiry date for an existing record.
  8. Scan through the mwrblblock table and create the two text files if configured.
  9. If configured compute a crc of the new and existing config file and run the custom command once the new file has been renamed.

Database Tables


clientip text ip address of the client
hour smallint hour of the day
count int number of emails sent to us
ham int number of which were ham
spam int number of which were definetly spam


setting text Used to store the name of a setting
value text Used to store the value of a setting


clientip text ip address of the client
expires text time and date when this record expires
errormsg text Error text to report back to the client saying why the mail was rejected.
"You have been blocked for sending more than minspamcount spam emails and no non-spam emails to us within a 23 hour period. You will be unblocked shortly after mwrblblock.expires"