Bonjour à la communauté et merci de me lire.

Je possède une caméra IP et je voudrais qu'à chaque passage devant un détecteur de mouvement celle-ci m'envoie un email avec la photo prise en pièce jointe.

J'ai trouvé sur le web un script qui fait cela à merveille

j'ai donc installé le script PHP sur mon petit NAS qui possède apache et PHP5

Tout fonctionne , je reçois bien le mail , les images sont bien uploadées sur mon serveur mais aucune pièce jointe juste du texte ...


D'où peut provenir le soucis ?

Voici le code :



Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
// -------------------------------------------------------------------------------------
// Domotics
// DHAS-send-snapshots-bymail v1
// 03 Mar 2012
// -------------------------------------------------------------------------------------
// Changes 
// v1.0 - get snapshot from cam and save to dis 
// -------------------------------------------------------------------------------------
 
require("/var/www/html/attach_mailer_class.php");
 
// Function
// Alternative Image Saving Using cURL seeing as allow_url_fopen is disabled - bummer
function save_image($img,$fullpath){
 $ch = curl_init ($img);
 curl_setopt($ch, CURLOPT_HEADER, 0);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
 $rawdata=curl_exec($ch);
 curl_close ($ch);
 if(file_exists($fullpath)) {
 chmod($fullpath, 755);
 unlink($fullpath);
 }
 $fp = fopen($fullpath,'x');
 fwrite($fp, $rawdata);
 fclose($fp);
}
 
// Main program
 
// Initialisation des Paramètres 
echo "Parametres : En cours ...<br/>";
$cam         = "http://admin:password@192.168.1.39/Streaming/channels/1/picture";
$tmp_folder = '/var/www/html/images/';
echo "Parametres : OK<br/><br/><br/><br/>";
 
// Capture des images
echo "Capture des snaphots : En cours ...<br/>";
save_image($cam,$tmp_folder.'img1.jpg');
sleep(1); 
save_image($cam,$tmp_folder.'img2.jpg');
sleep(1); 
save_image($cam,$tmp_folder.'img3.jpg');
sleep(1); 
save_image($cam,$tmp_folder.'img4.jpg');
sleep(1); 
save_image($cam,$tmp_folder.'img5.jpg');
echo "Capture des snaphots : OK<br/><br/><br/><br/>";
 
// Envoi du mail
 
echo "Envoi du mail : En cours ...<br/>";
$test = new attach_mailer($name = "DHAS", $from = "emetteur@mail.com", $to = "destinataire@mail.com", $cc = "", $bcc = "", $subject = "Alerte: Camera Ext. Avant ...");
$test->text_body = "Passage couloir ...<br/><br/><br/><br/>";
$test->add_attach_file("/var/www/html/images/img1.jpg");
$test->add_attach_file("/var/www/html/images/img2.jpg"); 
$test->add_attach_file("/var/www/html/images/img3.jpg"); 
$test->add_attach_file("/var/www/html/images/img4.jpg"); 
$test->add_attach_file("/var/www/html/images/img5.jpg"); 
$test->process_mail();
echo "Envoi du mail : OK<br/><br/><br/><br/>"; 
 
?>
Merci à tous pour votre expertise.


Nico