From: $name
Message: {$_POST['message']}
"; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From: $name <$email>"; $name=trim($name); $email=trim($email); $subject=stripslashes($subject); $message=stripslashes($message); $toaddress='brockie99@talk21.com'; //tyrrells function validate_email($email) { // Function to validate an e-mail address by both checking the // format of the address, and then testing it by holding an // authorisation conversation with the addresses SMTP server // // inputs - $Email = the email address itself // // returns - function has a return value of // 0 = success // 1 = failed, invalid address // 2 = system failure // global $HTTP_HOST; // Check for a malformed address (roughly) if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) { // it failed the simple format test, so return with an invalid address error return 1; } // otherwise it passes the test so we can go off and do the 'real' validation // // first split #Email up into parts list ( $Username, $Domain ) = split ("@",$email); // look for an MX record and get the mail host name if (checkdnsrr ( $Domain, "MX" )) { if (getmxrr ($Domain, $MXrec)) { // save the MX hostname ready for Phase 3 testing $Mailserver = $MXrec[0]; } else { // there is an MX record, but we failed to retrieve it return 2; // return system error NOT invalid address } } else { // in this case there isn't an MX record so assume that the domain // portion is also the name of the mail server itself (it can happen) // save it as the mailserver address ready for Phase 3 testing $Mailserver = $Domain; } // open a socket connection to the Mailserver if ($Connection = fsockopen($Mailserver, 25)) { // start the SMTP validation if (ereg("^220", $Rubbish = fgets($Connection, 1024))) { // it is an SMTP server so you can start talking to it // Tell it who you are and get the response (not needed later). fputs ( $Connection, "HELO $HTTP_HOST\r\n" ); $Rubbish = fgets ( $Connection, 1024 ); // Ask it to accept mail from your $email user - store the response (needed later) fputs ( $Connection, "MAIL FROM: <{$email}>\r\n" ); $Fromstring = fgets ( $Connection, 1024 ); // Ask it to accept mail for your $email user - store the response (needed later) fputs ( $Connection, "RCPT TO: <{$email}>\r\n" ); $Tostring = fgets ( $Connection, 1024 ); // Now tell it you're done with chatting fputs ( $Connection, "QUIT\r\n"); // and close the connection fclose($Connection); // finally test the resonses did we get OK (type 250) messages? if (ereg("^250", $Fromstring) && ereg("^250", $Tostring)) { // YAHOOO .. we got a good one return 0; // return successful validation } else { // the server refused the user return 1; // return invalid address } } else { // connected, to something but it failed to identfy itself as an SMTP server // so assume its a bogus address return 1; // return invalid address error } } else { // it failed to connect return 1; // return invalid address or system error - its your call } } if($send) { if(validate_email($email)==1) { $feedback = "Email Address Invalid!
"; //exit; } if(validate_email($email)==2) { $feedback = "An Error Occured! Please Try again
"; //exit; } if(validate_email($email) == 0){ mail($toaddress,$subject,$message,$headers); //clear the variables $name=''; $email=''; //$subject=''; $message=''; $feedback = "Email Sent Successfully!
"; //exit; } } ?>![]() |
![]() |
|
|
8, Park Lane | |
Seal | |
Nr Sevenoaks | |
Kent | |
TN15 0EE | |
Tel: 01732 762677 | |
Fax: 01732 763857 | |
Alternatively, you can contact us by completing the form below with any questions or enquiries you may have. |
PLEASE EMAIL OR CONTACT US DIRECTLY AS ABOVE AS THIS SECTION IS CURRENTLY UNDER GOING MAINTENANCE
This site was created by Alistair Brooker & Simon Fenn. Last Updated November 2007