Re: Quarantine ?

Cedric Fontaine <[email protected]> Wed, 20 Jan 2010 10:28:24 -0500
Newsgroups gmane.mail.qmail.scanner
Message-ID <[email protected]>
Hello,

I've been using this php script as a cronjob each day. It will parse all 
the mails in quarantine and will send a report to users each day.

Le 2010-01-19 23:41, Jason Haar a écrit :
> On 01/20/2010 05:01 AM, Stephane MAGAND wrote:
>> Hi
>>
>> I have installed QmailScanner and that's work very good. But i am
>> search a solution for:
>>
>> 1- Notify all user that he receive a email and this email are in
>> quanrantine.
>> 2-  a solution for see by a web interface all emails in quarantine and
>> a administor can unlock a quarantine msg.
>>
>> He have a sheel tools for list/delete or unlock a quarantine msg ?
>>
> Hello Stephane
>
> I'm afraid I have not heard of anyone writing such reporting tools -
> they would be a great addon to Qmail-Scanner. I have thought about
> writing them myself - but they wouldn't be a small task and I don't have
> much incentive myself to do it. Maybe someone else could...?
>

------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev

_______________________________________________
Qmail-scanner-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qmail-scanner-general
rapportspam.php (text/html, 3.9 KB)
<?php
/************************************************************************/
/* RAPPORTSPAM QMAILSCANNER                                             */
/* ===================================                                  */
/*                                                                      */
/* Cedric Fontaine [email protected]                            */
/* 13/07/2006                                                           */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/

// Necessite PEAR::mimeDecode
// pear install Mail_Mime

// Parametrage

// Chemin vers mimeDecode (fourni par Mail_Mime)
$mimeDecode="/usr/local/lib/php/Mail/mimeDecode.php";
// Chemin vers rcpthosts (listes des domaines locaux)
$qmailDomainDir="/var/qmail/control/rcpthosts";
// Chemin des repertoires de quarantaine a traiter
// ici volontairement on ne traite pas le repertoire des virus
$traitDir=array("/var/spool/qscan/quarantine/spam/new","/var/spool/qscan/quarantine/policy/new");
// Adresse IP locale de la machine - Permet de localiser l'heure de reception
$localIp="192.168.83.1";
// Expediteur du rapport
$fromEmail="[email protected]";

// DEBUT DU SCRIPT
include($mimeDecode);

$listdomt=file($qmailDomainDir);

$listdom="";
$montrait="";

foreach($listdomt as $domdom)
	$listdom[]=trim($domdom);

foreach($traitDir as $localDir) {
	if ($handle = opendir($localDir)) {
		while (false !== ($file = readdir($handle))) {
			if ($file != "." && $file != "..") {
				$filename=$localDir."/".$file;
				$handl2 = fopen($filename, "r");
				$input = fread($handl2, filesize($filename));
				fclose($handl2);
				$decode = new Mail_mimeDecode($input,"\n");
				$structure = $decode->decode();
				$rcv=$structure->headers['received'];
		
				foreach($rcv as $received) {
					if (strpos($received,"by ".$localIp." with SMTP;")!==false) {
						$dt=explode(";",$received);
						$dt=strtotime(array_pop($dt));
					}
				}
		
				if ($dt<time() && $dt<mktime(0,0,0) && $dt<mktime(0,0,0) - 86400 && $dt>mktime(0,0,0) - 172800) {
					$to=$structure->headers['to'];
					$pos=strpos($to,"<");
					if ($pos!==false)
						$to=substr($to,$pos+1);
					$pos=strpos($to,">");
					if ($pos!==false)
		  			$to=substr($to,0,$pos);
					$tomail=explode("@",$to);
					if (array_search($tomail[1],$listdom)!==false) {
						$subj=$structure->headers['subject'];
						$send=$structure->headers['from'];
						$montrait[$to][$file]['sujet']=$subj;
						$montrait[$to][$file]['expe']=$send;
					}
				}
			}
		}
		closedir($handle);
	}
}
foreach($montrait as $dest=>$cont){
	$tomail=explode("@",$dest);
	$monmail="Voici tous les spams que nous avons bloques les 24 dernieres heures.\nS'il y a des messages places ici en erreur selon vous, merci de nous contacter dans les 24h pour les recuperer, apres ce delai, les messages seront effaces.\nSi vous recevez du spam sur des adresses que vous n'utilisez pas contactez nous, nous vous aiderons a mieux traiter les mails recus.\nIl s'agit uniquement de certains mails pour lesquels le systeme pense fortement qu'il s'agit d'un spam (mail publicitaire, non sollicite). Ceci vient en complement des messages que vous recevez avec dans le sujet du message **SPAM** pour lesquels il y a une forte probabilite qu'il s'agisse d'un spam. Les messages places ici ne contiennent pas les messages ayant des virus, des pieces-jointes suspectes ou non conformes.\n\n";
	foreach($cont as $mesid=>$body) {
		$monmail.="Message ".$mesid."\n";
		$monmail.="Sujet : ".$body['sujet']."\n";
		$monmail.="Expediteur : ".$body['expe']."\n\n";
	
	}
	mail($dest,"Rapport de spam quotidien pour ".$dest,$monmail,"From: ".$fromEmail);
}
?>