2 e-mail in white or blacklist
Wess Bechard
mailscanner at ELIQUID.COM
Thu Dec 15 19:38:19 GMT 2005
[ The following text is in the "utf-8" character set. ]
[ Your display is set for the "US-ASCII" character set. ]
[ Some characters may be displayed incorrectly. ]
Mauricio,
You may want to clean up the code that inserts and removes emails from
your white/blacklists. As Julian mentioned, if you have a large number
of emails, you will waste resources processing the same emails over and
over.
I wrote a similar function in PHP. My PHP Mail app simply calls this
function with an email address, and a remove flag if you are removing an
email address.
This code snippit was written for the MailScanner whiltelist.
function spam($email, $remove = NULL) {
$filename = "/etc/MailScanner/rules/spam.whitelist.rules";
// We will read the values into an array, add or delete data, then
re-write the spam filter rules.
// If $remove = 1, delete the email, if not set, add the email.
// Read original values from spam filtering list...
$fp = fopen($filename, "r");
$initial_file = fread($fp, filesize($filename));
fclose($fp);
// Process and parse original file.
//Create an array element for each line in the
spam.whitelist.rules file.
$new_list = array();
$data = explode("\n", $initial_file);
$clean = array();
for ($i = 0; $i < sizeof($data); $i++) {
$data[$i] = $data[$i];
$line = explode(" ", $data[$i]);
$clean[$i][0] = $line[0];
$clean[$i][1] = $line[1];
$clean[$i][2] = $line[2];
}
if ($remove == '1') {
// If deleting, rebuild array of email addresses, but do not
include the email address provided.
for ($i = 0; $i < sizeof($clean); $i++) {
if (stristr($clean[$i][1], $email) === FALSE) {
if (!$clean[$i][1] == '') {
array_push($new_list, $clean[$i]);
}
}
}
} else {
// No remove flag set. We can add the provided email to
the array of addresses.
for ($i = 0; $i < sizeof($clean); $i++) {
if (stristr($clean[$i][1], $email) === FALSE) {
if (!$clean[$i][1] == '') {
array_push($new_list, $clean[$i]);
}
}
}
$array_size = sizeof($new_list);
$new_list[$array_size][0] = "To:";
$new_list[$array_size][1] = $email;
$new_list[$array_size][2] = "no";
}
// Write back array of email addresses to file.
if (!$fp = fopen($filename, "w+")) {
echo "ERROR! Could not open whitelist file.";
} else {
foreach($new_list as $current) {
fwrite($fp, $current[0] . " " . $current[1] . " " . $current[2] . "\n");
}
fclose($fp);
}
}
On Thu, 2005-12-15 at 18:55 +0000, Julian Field wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Mauricio Portilho Cavalcanti wrote:
>Hi,
>1) I made a web interface to insert and remove e-mails in white/blacklist.
>If someone puts de same e-mail twice, I think MS will treat as
>white/blacklist and no problem.
>
>From: fulano at domain.com.br yes
>From: fulano at domain.com.br yes
>
>Am I right?
>
>
Yes, that shouldn't cause any problem, but it will slow things down as
the ruleset is bigger than necessary.
>2) If I put @domain,com.br (",") in white/blacklist... how MS will treat
>this?
>
>
It won't match domain.com.br, it will end up being effectively ignored
as , will never appear in an address.
>Thanks in advance,
>Mauricio.
>
>------------------------ MailScanner list ------------------------
>To unsubscribe, email jiscmail at jiscmail.ac.uk with the words:
>'leave mailscanner' in the body of the email.
>Before posting, read the Wiki (http://wiki.mailscanner.info/) and
>the archives (http://www.jiscmail.ac.uk/lists/mailscanner.html).
>
>Support MailScanner development - buy the book off the website!
>
>
- --
Julian Field
www.MailScanner.info
Buy the MailScanner book at www.MailScanner.info/store
Professional Support Services at www.MailScanner.biz
MailScanner thanks transtec Computers for their support
PGP footprint: EE81 D763 3DB0 0BFD E1DC 7222 11F6 5947 1415 B654
-----BEGIN PGP SIGNATURE-----
Version: PGP Desktop 9.0.3 (Build 2932)
iQA/AwUBQ6G8FhH2WUcUFbZUEQIOTACfYR991YaxRiNRbkIA+M3avMSgBnsAn0Yu
KTtLUE+pRolP1GmAmHHL025Y
=vI61
-----END PGP SIGNATURE-----
___________________________________________
Wess Bechard
Information Technology Manager
eliquidMEDIA International Inc.
Visit: www.eliquid.com
Office: 519.973.1930 - 1.800.561.7525
Fax: 519.253.0337
Cell: 519.791.9492
___________________________________________
------------------------ MailScanner list ------------------------
To unsubscribe, email jiscmail at jiscmail.ac.uk with the words:
'leave mailscanner' in the body of the email.
Before posting, read the Wiki (http://wiki.mailscanner.info/)
and the archives (http://www.jiscmail.ac.uk/lists/mailscanner.html).
Support MailScanner development - buy the book off the website!
More information about the MailScanner
mailing list