Mi controllate questo script?
Questo script dovrebbe permettermi di inviare un file alla casella mail predefinita, solo che la mail arriva senza l'allegato (oltre a mancare il nome e il testo predefinito dentro la mail).
Qualcuno può trovare l'errore? Grazie!
Questo è il form della pagina di invio (in .htm)
Codice:
<form action="richiesta.php" method="post" name="form1" id="form1" target="_self">
Nome: <input name="nome" type="text" id="nome" size="41" style="background-color: #EDEDED; border: thin groove #D6D6D6;"><br>
E-mail: <input type="text" name="email" id="email" size="41" style="background-color: #EDEDED; border: thin groove #D6D6D6;"><br>
<br>
<input name="all" type="file" id="all"><br><br>
<input type="reset" name="Submit" value="reset" style="background-color: #FF9933; color: #3C0000; border: thin double Black;">
<input type="submit" name="Submit2" value="invia" style="background-color: #669933; color: #FFFF99; border: thin solid Black;" onClick="MM_validateForm('nome','','R','mail','','RisEmail','oggetto','','R','messaggio','','R');return document.MM_returnValue">
</form>
Questo è il codice della pagina in php che gestisce l'invio:
Codice:
<?php
# recupero dati form
$nome = $_POST['nome'];
$email = $_POST['email'];
$messaggio = "In allegato il documento";
$oggetto = "Invio allegato";
$casella = "prova@prova.it"; # INSERIRE QUI LA CASELLA DI POSTA DOVE INVIARE LA MAIL
# verifica dati inseriti
if(($nome<>"")&&($email<>"")){
# intestazioni della mail
$intestazioni = "MIME-Version: 1.0\n";
$intestazioni .= "Content-Type: multipart/mixed; boundary=\"XX-1234DED00099A\"\n";
$intestazioni .= "Content-Transfer-Encoding: 7bit\n";
$intestazioni .= "From: $email\n";
# testo della mail
$msg = "--XX-1234DED00099A\n";
$msg .= "Content-Type: text/plain; charset=iso-8859-1\n";
$msg .= "Content-Transfer-Encoding: 7bit\n\r";
$msg .= $messaggio;
# allegato della mail
$fp=@fopen($all, "r");
if ($fp) {
$data = fread($fp,filesize($all));
$msg .= "\n--XX-1234DED00099A\n";
$msg .= "Content-Type: application/octet-stream;name=\"$all_name\"\n";
$msg .= "Content-Transfer-Encoding: base64\n";
$msg .= "Content-Disposition: attachment;filename=\"$all_name\"\n";
$allegato = base64_encode($data);
$msg .= "$allegato";
}
# invio del mail
$result = @mail($casella,$oggetto,$messaggio,$intestazioni,$all);
# controllo risultato
if($result){
# invio eseguito
echo "<p>Il tuo messaggio è stato inoltrato con successo!</p><p>Grazie!</p>";
}else{
# errore server
echo "<p>E' stato riscontrato un errore sul server.<br>Impossibile inviare il messaggio.</p><p>Riprova più tardi.</p>";
} end;
}else{
# avviso insufficienza dati
echo "<p>Non hai compilato tutti i campi del modulo!</p><p>Campi mancanti:</p>";
if($nome==""){ echo "Nome<br>";}
if($email==""){ echo "Indirizzo e-mail<br>";}
} end; ?>
:cry:
Questo è l'header della mail che mi è arrivata
Return-Path: <user@server>
Received: from smtp-f4.localhost (smtp-server [212.25.179.68])
by server (8.13.4/8.13.4/Debian-3) with ESMTP id jBIG0fGc013753
for <indirizzo@mail.it>; Sun, 18 Dec 2005 17:00:41 +0100
Received: from localhost (localhost [127.0.0.1])
by smtp-f4.localhost (Postfix) with ESMTP id 480A64C70E
for <indirizzo@email.it>; Sun, 18 Dec 2005 17:00:40 +0100 (CET)
Received: by smtp-f4.localhost (Postfix, from userid 1000)
id E16E84C223; Sun, 18 Dec 2005 17:00:37 +0100 (CET)
Received: from server (server [217.64.195.220])
by smtp-f4.localhost (Postfix) with ESMTP id 6F8264C783
for <indirizzo@email.it>; Sun, 18 Dec 2005 17:00:34 +0100 (CET)
Received: from server (localhost.localdomain [127.0.0.1])
by server (8.13.4/8.13.4/Debian-3) with ESMTP id jBIG0XAS018251
for <indirizzo@email.it>; Sun, 18 Dec 2005 17:00:33 +0100
Received: (from asism.it@localhost)
by server (8.13.4/8.13.4/Submit) id jBIG0Xqs018250;
Sun, 18 Dec 2005 17:00:33 +0100
Date: Sun, 18 Dec 2005 17:00:33 +0100
Message-Id: <user@server>
To: indirizzo@email.it
Subject: Invio allegato
From: prova@prova.it
X-Priority: 3
To: indirizzo@email.it
Mime-Version: 1.0
Content-Type: multipart/mixed;
boundary="--41c1beab3c3ece288559dbc7ab908b7e"
Content-Transfer-Encoding: 8bit
X-Virus-Scanned: by AMaViS