<?PhpfunctionSpamcheck($field){Filter_var () filter e-mailUsing Filter_sanitize_email$field=Filter_var($field,Filter_sanitize_email);Filter_var () filter e-mailUsing Filter_validate_emailIf(Filter_var($field,Filter_validate_email)){ReturnTRUE;}Else{ReturnFALSE;}}If (Isset($_request[' Email '])){Send a message if you receive a mailbox parameterDetermine if a mailbox is legitimate$mailcheck=Spamcheck($_request[' Email ']);If ($mailcheck==FALSE){Echo"Illegal input";}Else{Send mail$email=$_request[' Email '] ;$subject=$_request[' Subject '] ;$message=$_request[' Message '] ;Mail("[Email protected]", "Subject: $subject",$message, "From: $email" );Echo"Thank you to using our mail form"; }}else{ ///If no mailbox parameters are present the form echo "<form method= ' post ' action= ' mailform.php ' > Email: <input name= ' email ' type= ' text ' ><br> Subject: <input name= ' Subject ' type= ' text ' ><br> message:<br> <textarea name= ' message ' rows= ' cols= ' > </textarea><br> <input typ E= ' Submit ' > </form> ';} ?>
PHP mail Anti-injection and implementation of classic code