# Exim filter # Allow mail delivery failures through if error_message then finish endif # Allow postmaster access if $original_local_part is postmaster then finish endif # if we have blacklisted this server, send the sender # a message telling them so. if ("${lookup{$sender_host_address} lsearch {$home/mailfilter/black.servers}{$value}}" is "black") then seen mail expand file $home/mailfilter/blh-bounce to $return_path return message subject "Returned mail: blacklisted" logfile $home/mailfilter/reject.log 0644 logwrite "[$tod_log] ${lc:$sender_address} [$sender_host_address] -> ${lc:$original_local_part}@${lc:$original_domain}: host already blacklisted" finish endif # if we have blacklisted this sender's domain, then send them # a mail telling them so. if ("${lookup{${domain:${lc:$sender_address}}} lsearch {$home/mailfilter/black.domains}{$value}}" is "black") then seen mail expand file $home/mailfilter/bld-bounce to $return_path return message subject "Returned mail: blacklisted domain" logfile $home/mailfilter/reject.log 0644 logwrite "[$tod_log] ${lc:$sender_address} [$sender_host_address] -> ${lc:$original_local_part}@${lc:$original_domain}: already blacklisted" if("${lookup{$sender_host_address} lsearch {$home/mailfilter/grey.servers}{$value}}" is "grey") then logwrite "[$tod_log] *** [$sender_host_address]: blacklisted host" logfile $home/mailfilter/black.servers 0644 logwrite "$sender_host_address: black" else if("${lookup{$sender_host_address} lsearch {$home/mailfilter/grey.servers}{$value}}" is "") then logfile $home/mailfilter/grey.servers 0644 logwrite "$sender_host_address: grey" endif endif finish endif # if we have blacklisted this sender, then send them # a mail telling them so. if ("${lookup{${lc:$sender_address}} lsearch {$home/mailfilter/black.list}{$value}}" is "black") then seen mail expand file $home/mailfilter/bl-bounce to $return_path return message subject "Returned mail: blacklisted" logfile $home/mailfilter/reject.log 0644 logwrite "[$tod_log] ${lc:$sender_address} [$sender_host_address] -> ${lc:$original_local_part}@${lc:$original_domain}: already blacklisted" if("${lookup{$sender_host_address} lsearch {$home/mailfilter/grey.servers}{$value}}" is "grey") then logwrite "[$tod_log] *** [$sender_host_address]: blacklisted host" logfile $home/mailfilter/black.servers 0644 logwrite "$sender_host_address: black" else if("${lookup{$sender_host_address} lsearch {$home/mailfilter/grey.servers}{$value}}" is "") then logfile $home/mailfilter/grey.servers 0644 logwrite "$sender_host_address: grey" endif endif finish endif # if we have seen this address in the use once list, it # is no longer valid. if ( ${lc:$original_local_part} matches "^(.*?)(-[a-z0-9-+=]*)?\\\$" ) then if ("${lookup{${lc:$1}} lsearch {$home/mailfilter/use.once}{$value}}" is "used") then seen mail expand file $home/mailfilter/used-bounce to $return_path return message subject "Returned mail: address no longer valid" logfile $home/mailfilter/reject.log 0644 logwrite "[$tod_log] ${lc:$sender_address} [$sender_host_address] -> ${lc:$original_local_part}@${lc:$original_domain}: reuse of a single-use address" finish endif endif # spambait addresses, will automatically blacklist you and mark # your server down as being grey or black if ( ${lc:$original_local_part} is "spamdump" or ${lc:$original_local_part} matches ^\\d?[a-z]{3}\\d+(-[a-z0-9+=-]*)?\$) then seen mail expand file $home/mailfilter/spam-bounce to $return_path return message subject "Returned mail: blacklisted" logfile $home/mailfilter/black.list 0644 logwrite "${lc:$sender_address}: black" logfile $home/mailfilter/reject.log 0644 logwrite "[$tod_log] ${lc:$sender_address} [$sender_host_address] -> ${lc:$original_local_part}@${lc:$original_domain}: blacklisted" if("${lookup{$sender_host_address} lsearch {$home/mailfilter/grey.servers}{$value}}" is "grey") then logwrite "[$tod_log] *** [$sender_host_address]: blacklisted host" logfile $home/mailfilter/black.servers 0644 logwrite "$sender_host_address: black" else if("${lookup{$sender_host_address} lsearch {$home/mailfilter/grey.servers}{$value}}" is "") then logfile $home/mailfilter/grey.servers 0644 logwrite "$sender_host_address: grey" endif endif finish endif # open relay warnings. If your server is already listed as # grey, then it is blacklisted by this. if ( $header_X-RBL-Warning contains "mail-abuse.org" ) then seen mail expand file $home/mailfilter/rbl-bounce to $return_path return message subject "Returned mail: blacklisted" logfile $home/mailfilter/reject.log 0644 if ( $header_X-RBL-Warning contains "mail-abuse.org" ) then logwrite "[$tod_log] ${lc:$sender_address} [$sender_host_address] -> ${lc:$original_local_part}@${lc:$original_domain}: on rbl (MAPS ONLY)" endif if("${lookup{$sender_host_address} lsearch {$home/mailfilter/grey.servers}{$value}}" is "grey") then logwrite "[$tod_log] *** [$sender_host_address]: blacklisted host" logfile $home/mailfilter/black.servers 0644 logwrite "$sender_host_address: black" endif finish endif # this is a use-once address, deliver it as normal, but # log the use of the address. if ( ${lc:$original_local_part} matches ^(^[a-z]{2}\\d{2}[a-z]{3}\\d{2})(-[a-z0-9+=-]*)?\$) then logfile $home/mailfilter/use.once 0644 logwrite "${lc:$1}: used" endif add 0 to n1 add 0 to n2 add 0 to n3 if ( $tod_log matches "^(\\\\d{4})-0*(\\\\d+)-0*(\\\\d)\\\\s" ) then add $1 to n1 add $2 to n2 add $3 to n3 endif if ( ${lc:$original_local_part} matches "^\\\\$0*(\\\\d+)\\\\$0*(\\\\d+)[a-z]0*(\\\\d+)\\\\d\\$(-[a-z0-9-+=]*)?\\\$" ) then add $1 to n6 add $2 to n4 add $3 to n5 add 1977 to n4 add -52 to n5 add -9 to n6 if ( ( $n1 is above $n4 ) or ( $n1 is $n4 and $n2 is above $n5 ) or ( $n1 is $n4 and $n2 is $n5 and $n3 is above $n6 ) or ( $n4 is below 1 or $n5 is below 1 or $n6 is below 1 ) ) then seen mail expand file $home/mailfilter/time-bounce to $return_path return message subject "Returned mail: address no longer valid" logfile $home/mailfilter/reject.log 0644 logwrite "[$tod_log] ${lc:$sender_address} [$sender_host_address] -> ${lc:$original_local_part}@${lc:$original_domain}: address timed out (expired $n4-$n5-$n6)" finish endif endif # scoring algorithms, I don't tend to get these in legitimate mail. # we'll use n9 for scoring - 100 and we reject the mail if( ${lc:$message_body} matches "a\\\\shref=(['\"])mailto:([^@]@[^@])\$1" and $2 is not {$lc:$return_path} and $2 is not {$lc:$sender_address}) then add 60 to n9 endif if (${lc:$message_body} matches "") then add 60 to n9 endif if (${lc:$message_body} matches " ${lc:$original_local_part}@${lc:$original_domain}: score failure" finish endif