Sto utilizzando lo script di freephp per alleare file alla mail e spedirla.

Funziona tutto solo che quando apro l'allegato questo è vyoto, 0 byte, mentre il file che mi viene generato si trova nella sua directory bello e pronto.

Il nome del file è repA_01_01_2005.html

Di seguito il cordice:

La variabile $fileName=repA_01_01_2005.html e $Destinatari gli indirzzi di posta di chi riceve la mail


Grazie a tutti per l'aiuto.

Codice PHP:

<?php 

function send_mail($fileName,$Destinatari

     
// ASSEGNIAMO A VARIABILI PIU' LEGGIBILI, LE PROPRIETA' DELL'ALLEGATO 
     
$attach $fileName
     
$file_name $fileName
     
$file_type 'text/html';  
     
$file_size filesize($fileName); 
     
$Soggetto="automatic report"
     
     
// DELIMITATORE 
     
$boundary md5(uniqid(microtime())); 
     
     
// APRIAMO L'ALLEGATO PER LEGGERLO E CODIFICARLO 
     
$file = @fopen($attach"r"); 
     
$contents = @fread($file$file_size); 
     
$encoded_attach chunk_split(base64_encode($contents)); 
     @
fclose($file); 
     
     
// INTESTAZIONI DELLA MAIL 
     
$mail_headers .= "MIME-version: 1.0\n"
     
$mail_headers .= "Content-type: multipart/mixed; boundary=\"$boundary\""
     
$mail_headers .= "X-attachments: $file_name\n"
     
     
// COSTRUIAMO IL CORPO DELLA MAIL 
     
$mail_body "--$boundary\n"
     
$mail_body .= "Content-Type: text/plain; charset=us-ascii\n"
     
$mail_body .= "Content-Transfer-Encoding: 7bit\n\n"
     
$mail_body .= "$Contenuto\n\n"
     
$mail_body .= "--$boundary\n"
     
$mail_body .= "Content-type: $file_type; name=\"$file_name\"\n";  
     
$mail_body .= "Content-Transfer-Encoding: base64\n"
     
$mail_body .= "$encoded_attach\n"
     
$mail_body .= "--$boundary--\n"
     
     
// INVIO DELLA MAIL 
    
@mail($Destinatari$Soggetto$mail_body$mail_headers); 



?>