Questo è l'intero codice, l'utente ha anche la possibilità di ricevere una mail di conferma:
<?
header("Pragma: no-cache");
header("Cache-Control: no-cache, must-revalidate");
if(isset($_POST['Submit'])){
$to = "xxxxx@xxxx.it";
$to2 = $_POST['email'];
$from2 = "miamail@xxx.it";
$subject2 = "Conferma spedizione dell'email dal sito www.miosito.it";
$body2 = "Grazie, $email\n L'e-mail è stata spedita in modo corretto.\n A presto\n www.miosito.it";
$extraInfo = "Questa Email ti è stata spedita da (IP address " . getenv("REMOTE_ADDR") . "):\n\n";
$subject = "Mail da Sito: " . $_POST['nome'] . " " . $_POST['cognome'];
$body = "Da: " . $_POST['nome'] . ", " . $_POST['cognome'] . "\n";
$body .= "Testo del messaggio: " . utf8_decode($_POST['messaggio']) . "\r\n";
$body .= "Da: $to2";
if (@mail($to, $subject,$extraInfo . $body, "From: $email\nX-Mailer: PHP/" . phpversion())){
if($_POST['desideri'] == "true"){
mail($to2, $subject2,$extraInfo . $body2, "Return-Path: <miamail@xxxxx.it>\r\n" . "From: $from2\r\n" . "Reply-to: miamail@xxxxx.it\r\n" . "X-Mailer: PHP/" . phpversion());
}
echo "attenzione=" . urlencode("Email succesfully sent");
} else {
echo "attenzione=" . urlencode("Some errors occurred");
}
}
?>
Grazie per l'attenzione.