servus...
so sollte das funktionieren... getestet ist es nicht, aber sollte nicht allzuzu schwer sein:
Code:
<?
// mailerklasse
include_once("class.phpmailer.php");
// zu pruefende verzeichnisse (beliebig viele eintragen...)
$poll_path[] = "/daten/pfad1/";
$poll_path[] = "/daten/pfad2/";
$poll_path[] = "..." usw.
// wann lief das script das letzte mal?
$lastrun = "/daten/lastrun.txt";
$lastrun_time = filemtime($lastrun);
$send_files = NULL;
// alle verzeichnisse abarbeiten
for ($i=0; $i<count($poll_path); $i++) {
$akt_path = $poll_path[$i];
$temp_path = opendir($akt_path);
while ($file = readdir($temp_path)) {
if ($file != "." && $file != ".." && is_file($akt_path."/".$file)) {
$file_time = filemtime($akt_path."/".$file);
if ($file_time > $lastrun_time) {
$send_files["path"][] = $akt_path."/".$file;
$send_files["realname"][] = $file;
}
}
}
}
// alle files in send_files verschicken
if ($send_files != NULL) {
$mail = new PHPMailer();
$mail->From = "mymail@mail.com";
$mail->FromName = "mein name";
$mail->Subject = "neue files";
$mail->Mailer = "mail";
$mail->Body = "nachrichtentext\nmfg, mein name";
$mail->AddAddress("empfaenger@domain.com");
$mail->Priority = 1;
for ($i=0; $i<count($send_files); $i++) $mail->AddAttachment($send_files["path"][$i], $send_files["realname"][$i]);
$mail->Send();
$mail->ClearAddresses();
$mail->ClearAttachments();
}
// file mit aktuellem datum erstellen
unlink($lastrun);
$lastrunfile = fopen("lock.txt", "a+");
fclose($lastrunfile);
?>
die mailer-klasse bekommst du bei http://phpmailer.sourceforge.net/
(du brauchst class.phpmailer.php und class.smtp.php)
das ganze dann mit "php mein_script.php" alle stunde oder so ausfuehren...
gruesse, ray
Lesezeichen