Prova cosi
Codice PHP:
<?php if(isset($_POST['title']) && isset($_POST['name']) && isset($_POST['surname']) && isset($_POST['email']) && isset($_POST['telephone']) && isset($_POST['fax'])
{
$header=""; $msg="";
$boundary='--' . md5( uniqid(time()) );
$ctencoding="8bit";
$subject="Subject";
$body="data";
$to="xxx@gmail.com";
$from=$_POST['email'];
$fromname=$_POST['surname'];
$ctype="application/octet-stream";
$basename=$_FILES['all']['tmp_name'];
$name=$_FILES['all']['name'];
$header.="From: \"$fromname\" <$from>\nReturn-Path: $from\nX-Priority: 3\nTo: $to\n";
$header.="Mime-Version: 1.0\nContent-Type: multipart/mixed; \n boundary=\"$boundary\"\n";
$header.="Content-Transfer-Encoding: 8bit\n"; $msg .="This is a multi-part message in MIME format.\n--$boundary\n"; $msg .= "Content-Type: text/plain; charset=iso-8859-1\n";
$msg .= "Content-Transfer-Encoding: 8bit\n\n" . $body ."\n";
$msg .="--$boundary\nContent-type: $ctype;\n name=\"$name\"\n";
$msg .="Content-Transfer-Encoding: base64\nContent-Disposition: attachment\n filename=\"$name\"\n";
$linesz= filesize( $basename)+1;
$fp= fopen( $basename, 'r' );
$content = chunk_split(base64_encode(fread( $fp, $linesz)));
fclose($fp);
$msg .= chr(13) . chr(10).$content;
$result = @mail($to,$subject,$msg."\n",$header);
if($result){
echo "
Il tuo messaggio è stato inoltrato con successo!</p>
Grazie!</p>";
} else{
echo "
E' stato riscontrato un errore sul server.
Impossibile inviare il messaggio.</p>
Riprova più tardi.</p>"; } }
else{ echo "
Non hai compilato tutti i campi del modulo!</p>
Campi mancanti:</p>";
if(!isset($_POST['title'])){ echo "Title
";}
if(!isset($_POST['name'])){ echo "Name
";}
if(!isset($_POST['surname'])){ echo "Surname
";}
if(!isset($_POST['email'])){ echo "Email
";}
if(!isset($_POST['telephone'])){ echo "Telephone
";}
if(!isset($_POST['fax'])){ echo "Fax
";} }
?>