ciao filippo, si lo so' che non invia e solo il modulo per i campi del nome, del sito ed della email. L'email che mi arriva funziona bene con il file php, e solo che mi visualizza i nomi del pulsante,cioe' (Submit: Invia!)
comunque il file php e questo che invia(quello ceh dicevi tu)
emails.php
-----------------------------------
<?php
$myemail = "miaemail@mail.com";
$thankyou = "Email spedita correttamente.";
$allowed_fileuploads = "png gif jpg ";
if(!$_POST)
die('Please don\'t access this file directly.');
while(list($key,$val) = each($_POST)) {
if(stristr($key,'REQUIRED')){
$key = str_replace('REQUIRED','',$key);
$fields[$key] = $val;
if($val == ''){
$missing[] = ''.$key.'';
}
} else {
$fields[$key] = $val;
}
}
if(isset($fields['myemail']))
$myemail = $fields['myemail'];
if(isset($fields['name'])){ $name = $fields['name']; } else { $name = "aMAILzing"; }
if(isset($fields['email'])){ $email = $fields['email']; } else { $email = $myemail; }
if(isset($fields['subject'])){ $subject = $fields['subject']; } else { $subject = "Web Form"; }
reset($_POST);
$injection = false;
foreach($_POST as $key => $value){
if(preg_match("/(content-type|bcc:|cc:|script|onclick|onmouseover)/i", $value)){
$injection = true;
}
}
$message = "Email proveniente dal sito pmkristal!\n";
$message .= "-----------------------------------------------------------\n";
$message .= "Ip: ".$_SERVER['REMOTE_ADDR']."\n";
$message .= "Host: ".@gethostbyaddr($_SERVER['REMOTE_ADDR'])."\n";
$message .= "Browser: ".$_SERVER['HTTP_USER_AGENT']."\n";
$message .= "Referrer: ".$_SERVER['HTTP_REFERER']."\n\n";
foreach($fields as $k=>$v) {
if($v && !stristr($k,'REQUIRED'))
if(is_array($v))
$message .= ucfirst($k).": ".implode(', ', $v)."\n\n";
else
$message .= ucfirst($k).": $v\n\n";
}
$message .= "-----------------------------------------------------------\n";
$message .= "Creata da - http://www.pmkristal.com";
$message = stripslashes($message);
$mail_boundary = "x".md5(time())."x";
$header = "From: $name <$email>\n";
$header .= "MIME-Version: 1.0\n";
$header .= "Content-type: multipart/mixed; boundary=\"{$mail_boundary}\"\n";
$header .= "X-Priority: 3\n";
$header .= "X-MSMail-Priority: Normal\n";
$header .= "X-Mailer: Creata da http://www.pmkristal.com\n";
$header .= "This is a multi-part message in MIME format.\n\n";
$header .= "--{$mail_boundary}\n";
$header .= "Content-type: text/plain; charset=\"iso-8859-1\"\n";
$header .= "Date: ".date('R')."\n";
$header .= "Content-Transfer-Encoding:7bit\n\n";
$header .= $message."\n\n";
// Attach the uploaded files, if there is any.
if($_FILES){
if (get_magic_quotes_runtime() == 1){
set_magic_quotes_runtime(0);
}
foreach($_FILES as $key=>$value){
foreach($value as $key2 => $value2){
$$key2 = $value2;
}
if (is_uploaded_file($tmp_name)) {
if(isset($allowed_fileuploads)){
$fileextensions = explode(' ', $allowed_fileuploads);
$thisfile = explode('.', $name);
$thisfile = array_pop($thisfile);
if(!in_array($thisfile, $fileextensions)){
die("Spiacente ma i file zippati non sono consentiti.");
}
}
$fp = fopen($tmp_name,'rb');
$read = fread($fp,$size);
fclose($fp);
$file = base64_encode($read);
$file = chunk_split($file);
$header .= "--$mail_boundary\n";
$header .= "Content-type: $type; name=\"$name\"\n";
$header .= "Content-Transfer-Encoding:base64\n";
$header .= "Content-Disposition: attachment; filename=\"$name\"\n\n";
$header .= $file."\n\n";
}
}
}
// Now, lets deal with what we've got so far!
$valid_email = eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email);
if(!isset($missing) && $valid_email && $injection != true) {
mail($myemail,$subject,'',$header);
} elseif(!$valid_email){
$thankyou = "La tua email non e' valida- Riprova di nuovo.";
} elseif($injection == true){
die("Email injection attempt detected and blocked.");
} else {
if(count($missing)>1){
$last = array_pop($missing);
$themissing = implode(', ',$missing).' and '.$last;
$plu = 's';
} else {
$themissing = $missing[0];
}
$thankyou = "Sorry, but you do not seem to have filled out the field$plu ".$themissing.". Please go back and fill out all the required fields!";
}
// And, in the very end, we've got to catch the referrers and redirect back to where we came from.
$ref = getenv("HTTP_REFERER");
if (stristr($ref,'?'))
$sep = "&";
else
$sep = "?";
$thankyou .= ' .';
$thankyou = urlencode($thankyou);
header("Location: $ref${sep}message=$thankyou");
?>