garyb10 Posted June 20, 2010 Share Posted June 20, 2010 Hi All, I have been using this mail script for about 6 month. Every thing worked fine(except for sticking from after the body) until this week. Now it doesn't work and no errors. Maybe I have been looking at it too long, but I can't find anything wrong. Can anyone spot whats wrong? $to = "[email protected]"; $subject = $_REQUEST["subject"]; $body = $_REQUEST["body"]; $email = $_REQUEST["email"]; $name = $_REQUEST["name"]; $dodgy_strings = array( "content-type:" ,"mime-version:" ,"multipart/mixed" ,"bcc:" ); function is_valid_email($email) { return preg_match('#^[a-z0-9.!\#$%&\'*+-/=?^_`{|}~]+@([0-9.]+|([^\s]+\.+[a-z]{2,6}))$#si', $email); } function contains_bad_str($str_to_test) { $bad_strings = array( "content-type:" ,"mime-version:" ,"multipart/mixed" ,"Content-Transfer-Encoding:" ,"bcc:" ,"cc:" ,"to:" ); foreach($bad_strings as $bad_string) { if(eregi($bad_string, strtolower($str_to_test))) { echo "$bad_string found. Suspected injection attempt - mail not being sent."; exit; } } } function contains_newlines($str_to_test) { if(preg_match("/(%0A|%0D|\\n+|\\r+)/i", $str_to_test) != 0) { echo "newline found in $str_to_test. Suspected injection attempt - mail not being sent."; exit; } } if($_SERVER['REQUEST_METHOD'] != "POST"){ echo("Unauthorized attempt to access page."); exit; } if (!is_valid_email($email)) { echo 'Invalid email submitted - mail not being sent.'; exit; } contains_bad_str($email); contains_bad_str($subject); contains_bad_str($body);//replace body with $body contains_newlines($email); contains_newlines($subject); $body = $body . " From: " . $name; $headers='MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html;charset=iso-8859-1' . "\r\n"; $headers .= "From: $email" . "\r\n"; mail ($to, $subject, $body, $headers); echo "Thanks for submitting."; Link to comment https://forums.phpfreaks.com/topic/205327-php-mail-quit-working/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.