Morthland, Cam typed this on 03/12/2004 02:10 PM:
This is exactly what I want to do since amavis need to be stopped and
started to load new whitelist.  Any syntax help would be appreciated.  I
can prolly figure out the php part, but I do not know perl or anything
to do the "back-end" stuff.

Thanks,

Cam

whitelist.php


#!/usr/local/bin/php
<?php


# /path/to/files $file = "emails.txt"; $spam_config = "local.cf";


# Open file if (!$fp = fopen($file, "r")) die ("Could not open file: ". $file);


# Loop through each line in file while (!feof($fp)) { $buffer = fgets($fp, 1024); if ($buffer != "") { $output .= "whitelist_from " . $buffer; } }


# close file fclose($fp);


if(!$fp = fopen($spam_config, "w")) die ("Could not open file for writing: " . $spam_config);


if (!fwrite($fp, $output)) die("Unable to write to file.");


#close file fclose($fp);

?>

My emails.txt file contains:
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]

The output in local.cf had:
whitelist_from [EMAIL PROTECTED]
whitelist_from [EMAIL PROTECTED]
whitelist_from [EMAIL PROTECTED]

Of course, you'd probably want to add some code to validate that the email is correct and check for weird characters and such so spamassassin doesn't choke on anything in the config.

Goodluck!

-Robby

--
Robby Russell,  |  Sr. Administrator / Lead Programmer
Command Prompt, Inc.   |  http://www.commandprompt.com
[EMAIL PROTECTED] | Telephone: (503) 222.2783
_______________________________________________
PDXLUG mailing list
[EMAIL PROTECTED]
http://pdxlug.org/mailman/listinfo/pdxlug

Reply via email to