| |||||||||||||||||||||||||||||||
|
i want to show you my solution about how to fight backscatter, pleas tell me what do you think about that: The concept is to store in a whitelist-db To and CC emails of my outbound emails, and when i receive an email with a delivery error, check if the Final-Recipient is in my whitelist. I've implemented it in 2 php files, one must be run for each outgoing email, and the other one for each incoming email. /* ************************ FOR EACH OUTGOING EMAIL */ <?php /* the content of the email can be retrieved or by stdin or by reading it from a tmpfile */ $content = file_get_contents("Sent"); /* look only in the headers of the email */ $headers = strtoupper(substr($content,0,strpos($content,"Content-Type:"))); /* retrieve To: and CC: destinations */ $start_to = strpos($headers,"\nTO:"); $start_cc = strpos($headers,"\nCC:"); $start_subject = strpos($headers,"\nSUBJECT:"); if($start_cc!==false){ $to = substr($headers,$start_to,$start_cc-$start_to); $cc = substr($headers,$start_cc,$start_subject-$start_cc); }else{ $to = substr($headers,$start_to,$start_subject-$start_to); } $res_to = get_address($to); $res_cc = get_address($cc); $final_email = array_merge($res_to,$res_cc); foreach($final_email as $email){ /* store email in my backscatter whitelist */ } /** * return an array filled with the emails found in $address */ function get_address($address){ $results = array(); $address = explode(",",$address); foreach($address as $email){ if(strpos($email,"<")!==false){ $mail = substr($email,strpos($email,"<")+1,strpos($email,">")-strpos($email,"<" )-1); }else{ $mail=$email; } $mail = trim($mail); array_push($results,$mail); } return $results; } ?> /* ************************ FOR EACH INCOMING EMAIL */ <?php $content = file_get_contents("backscatter"); $final_recipient = strpos($content,"Final-Recipient: rfc822;"); if($final_recipient!==false){ /* this is a mail with a delivery failure i try to retrieve the original destination of the email */ $email_final_recipient = substr($content,$final_recipient,strpos($content,"\n",$final_recipient)-$final_r ecipient); $email_final_recipient = substr($email_final_recipient,strlen("Final-Recipient: rfc822;")); $email_final_recipient = trim($email_final_recipient); $email_final_recipient = strtoupper($email_final_recipient); /* now i check if the email is in my backscatter whitelist */ check.... }else{ /* OK, this email isn't a mail with a delivery failure */ } ?> -- /*************/ nik600 https://sourceforge.net/projects/ccmanager https://sourceforge.net/projects/reportmaker https://sourceforge.net/projects/nikstresser
| ||||||||||||||||||||||||||||||
© 2004-2008 readlist.com