qui su AV devi utilizzare la funzione @mail() , come esempio ho realizzato una funzione che sfrutta mail() per una applicazione su file:
Codice PHP:
function send_mail($post,$subject,$user_name,$pass_word,$email_address)
{
//CONTROLLO HACKERS
if(!is_secure($post)) {
$subject = "Hack Attempt via Contact Form!";
$body = " - Indirizzo IP: ".getenv("REMOTE_ADDR")."
- Agent: ".getenv("HTTP_USER_AGENT")."";
$emailto = "eurosalute@altervista.org";
$headers = "From: $emailto";
@mail($emailto, $subject, $body, $headers);
die("<br><br><font color=\"red\"><b>Possibile Attacco Hackers !</b></font><br><br>");
}
//end CONTROLLO HACKERS
$to = $email_address;
$from = "eurosalute@altervista.org";
$subject = "".$user_name." - ".$subject."";
$contenuto = "Username: ".$user_name."<br>Password: ".$pass_word."<br>Email: ".$to."";
$body = nl2br("\nMessaggio:\n__________\n".stripslashes($contenuto)."\n\nFrom: ".stripslashes($from)."\n__________\nFine Messaggio.\n");
$headers = "MIME-Version: 1.0\r\n" ;
$headers .= "Content-Type: text/html; charset=iso-8859-1\r\n";
$headers .= "Content-Transfer-Encoding: 8bit\r\n";
$headers .= "From: ".$from."\r\n";
if(@mail($to, $subject, $body, $headers)) return true;
else return false;
}
function is_secure($ar) {
$reg = "/(Content-Type|Bcc|MIME-Version|Content-Transfer-Encoding)/i";
//echo "<p>";print_r($ar);
if(!is_array($ar)) {return preg_match($reg,$ar);}
$incoming = array_values_recursive($ar);
//echo "<p>";print_r($incoming);
foreach($incoming as $k=>$v) if(preg_match($reg,$v)) return false;
return true;
}
function array_values_recursive($array) {
$arrayValues = array();
foreach ($array as $key=>$value) {
if (is_scalar($value) || is_resource($value)) {
$arrayValues[] = $value;
$arrayValues[] = $key;
}
elseif (is_array($value)) {
$arrayValues[] = $key;
$arrayValues = array_merge($arrayValues, array_values_recursive($value));
}
}
return $arrayValues;
}
per richiamare la funzione,esempio:
Codice PHP:
if (send_mail($_POST,"Registrazione Effettuata !",$us,$pw,$email)) echo "<p></p>Registrazione Effettuata!<p></p>Username: $us<br>Password: $pw<br>Email: $email<p></p>Un Email è stato inviato con i dati di Registrazione.";
else echo "<p>Errore: L'invio del Email non è Riuscito!";