Originariamente inviato da danieledani
ho apportato alcune modifiche, così ricevo l'allegato MA E' VUOTO...

Aiutatemi per favore...
grazie


<?
$subject = "Copia file";
$attach = "d:/inetpub/webs/sitocom/file/file.txt";
$posta = "no-reply@sito.com";
$to = "destinatario@sito.com";

// INTESTAZIONI DELLA MAIL
$headers .= "MIME-version: 1.0\n";
$headers .= "Content-type: multipart/mixed; boundary=\"XX-1234DED00099A\"\n";
$headers .= "Content-Transfer-Encoding: 7bit\n";
$headers .= "From: " .$posta;

// Corpo del messaggio
$messaggio = "--XX-1234DED00099A\n";
$messaggio .= "Content-Type: text/plain; charset=iso-8859-1\n";
$messaggio .= "Content-Transfer-Encoding: 7bit\n\r";
$messaggio .= "\n Messaggio \n";
$messaggio .= "--XX-1234DED00099A\n";
$messaggio .= "Content-Type: application/octet-stream; name=\"$attach\"\n";
$messaggio .= "Content-Transfer-Encoding: base64\n";
$messaggio .="Content-Disposition: attachment\n\r";

$fp=@fopen($attach, "r");
if ($fp) { $data = fread($fp, filesize($attach)); }
$allega = base64_encode($data);

$messaggio .= "$allega";
$messaggio .= "--XX-1234DED00099A--\n";

$sentOK = mail($to, $subject, $messaggio, $headers);
if ($sentOK==1)
{
echo "invio OK, tutto regolare ";
}
else { echo "invio KO.."; }
?>
Qualche suggerimento???