Codice PHP:
<?php
/*la funzione mail richiede 4 parametri (l'ultimo è opzionale)*/
// 1) DESTINATARIO (da settare)
$destinatario = 'mia@email.it';
// 2) OGGETTO (da settare a prorpio piacimento)
$oggetto = 'Email dal tuo sito';
// 3) TESTO (da filtrare opportunamente... io l'ho fatto sbrigativamene con trim è strip_tags)
$_POST = array_map("trim", $_POST);
$_POST = array_map("strip_tags", $_POST);
$testo_mail = '<html><body>';
foreach($_POST as $key => $value)
{
$testo_mail .= '
'.$key': '.$value.'</p>';
}
$testo_mail .= '</body></html>';
// 4) HEADERS (per inviare info aggiuntive e/o formattare la mail in html)
$header = "MIME-Version: 1.0\n";
$header .= "Content-type: text/html; charset=iso-8859-1\n";
$header .= "From: sito.it <mia@email.it> \n";
$header .= "To: ".$destinatario."\n";
@mail($destinatario, $oggetto, $testo_mail, $header) or die ("Il tuo server non permette l'invio di email");
?>