Il seguente form mail che consente di inviare email con allegata una fotografia funziona, però vorrei sapere che tipo di modifiche sono necessarie per visualizzare nel testo della mail anche il contenuto dei form di testo (nell'esempio sotto riportato Nome e Email).
Non sono molto pratico di programmazione Php....spero che qualcuno mi sappia dare delle indicazioni in merito.
Questa è la form:
<form action="mail.php" enctype="multipart/form-data" 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;">
E-mail: <input type="text" name="email" id="email" size="41" style="background-color: #EDEDED; border: thin groove #D6D6D6;">
<input name="all" type="file" id="all">
<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');re
turn document.MM_returnValue">
</form>
--------------------------------------------------------------------------------
Qesto il codec PHP:
<?php
if(isset($_POST['email']) && isset($_POST['nome'])){
$header="";
$msg="";
$boundary='--' . md5( uniqid("myboundary") );
$ctencoding="8bit";
$subject="Invio allegato";
$body="In allegato il documento";
$to="TUA@MAIL.IT";
$from=$_POST['email'];
$ctype="application/x-unknown-content-type";
$basename=$_FILES['all']['tmp_name'];
$name=$_FILES['all']['name'];
$header.="From: $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-9\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['nome'])){ echo "Nome
";}
if(!isset($_POST['email'])){ echo "Indirizzo e-mail
";}
}
?>