Hi All,
I'm haveing some problems with my perl code. the script is for a mail filtering program called mimedefang, the code is the main filter.
the fist bit of code is used to filter out mail based on the subject line.
sub filter_begin () {
my($msgSubject, $hfile) = @_;
# ALWAYS drop messages with suspicious chars in headers
if ($SuspiciousCharsInHeaders) {
md_graphdefang_log('suspicious_chars');
action_quarantine_entire_message("Message quarantined because of suspicious characters in headers");
# Do NOT allow message to reach recipient(s)
return action_discard();
}
# Subject check
my($msgSubject);
my($hfile) = "HEADERS";
while(<HEADERS>) {
chomp;
$line = $_;
$idx = index($line, "Subject: ");
if (idx == 0){
$msgSubject = substr($line, 9);
}
}
if (($msgSubject =~ /RE: [A-Z] {2,},(?: [A-Z]+!?)+/) ||
($msgSubject =~ /\bparis hilton\b/ )) {
#Bounce the mail!
action_bounce("Forbiden subject matter - Rejected");
}
this next bit is used to move any mail tagged as spam to an admin/spam folder on the server, following this is the code used to append a header to say that the virus scan was performed and no virus was found.
# If SpamAssassin found SPAM, append report. We do it as a separate
# attachment of type text/plain
sub filter_end ($) {
my($entity) = @_;
if ($message_is_spam) {
# Add a header with original recipients, just for info
action_add_header("X-Orig-Rcpts", join(", ", @Recipients));
# Remove original recipients
foreach $recip (@Recipients) {
delete_recipient($recip);
}
# Send to spam address
add_recipient('admin@andi.com');
}
#virus checked header
if ($FoundVirus) {
action_add_header("X-virus_checked", "$FoundVirus");
}
the problem that i have is that the code is in place but is not doing anything at the moment. i am not a perl coder and am only guessing at the code. if you can see anything missing or undecleard or just have suggestions they will be welcome.
attached (i hope) is the acctual perl script fillter, so you can see where these bits fit in.
thanks for looking,
spikes