toker Posted February 3, 2008 Share Posted February 3, 2008 I always used this php file - worked great. moved servers some time ago and now it is not working anymore. tried everything but it is not gonna happen I guess here the file (where does it go wrong?) <style type="text/css"> <!-- .php_serious { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 15px; color: #00FF00; } --> </style> <?php //Initialize PHP //Checks if an email pattern is okay function emailOK($str) { //Check empty if(empty($str)) return false; //Check for @ if(!ereg("@",$str)) return false; //Check for at least 1 dot if(!ereg("\.",$str)) return false; //Get a user and a host list($user, $host) = explode("@", $str); //Make sure we have a user and host if((empty($user)) || (empty($host))) return false; //These characters are not allowed in email addresses $badChars = "[ ]+| |\+|=|[|]|{|}|`|\(|\)|,|;|:|!|<|>|%|\*|/|'|\"|~|\?|#|\\$|\\&|\\^|www[.]"; return !eregi($badChars, $str); }//End Function //This function reads any file and spits out its contents in the return function readTextFile($file){ if(!($fp=@fopen($file,"r"))) return false; //Read the file $fileContent=""; while (!feof($fp)) { $fileContent.= fgets($fp, 1024); }//End while loop //Close the file if(!fclose($fp)) return false; return($fileContent); }//End function //Plain text email sending function function sendMsg($to, $toEmail, $sub, $msg, $from, $fromEmail) { //Compose headers for plain text email $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/plain; charset=iso-8859-1\r\n"; $headers .= "X-Mailer: PHP/".phpversion()."\r\n"; //The mailer name $headers .= "From: ".$from."<".$fromEmail.">\r\n"; $headers .= "Reply-to: ".$from."<".$fromEmail.">\r\n"; //Compose recipient $recipient = empty($to) ? $toEmail : $to."<".$toEmail.">"; return mail($recipient, $sub, $msg, $headers); }//End function //Cleans up a string by trimming it //if magic_quotes are on.. then stripslashes as well function cleanUpData($data){ $data=trim($data); if(get_magic_quotes_gpc()){ $data=stripslashes($data); }//End if return($data); }//End function //Sends email from Flash Data function flashEmail($postVars){ //These variables in $postVars came from Flash //They are urlencoded for safe transfers //So we have urldecode them and then we trim them $name = cleanUpData(urldecode($postVars["name"])); $email = cleanUpData(urldecode($postVars["email"])); $message = cleanUpData(urldecode($postVars["message"])); /*ERROR CHECKING*/ //Email is required if (empty($email)) { $status = "You have not filled in your email address!\n\nThe message could not be send."; die("status=".urlencode($status)."&sent=0&"); }//End if //Check if email is okay.. if (!emailOK($email)) { $status = "This is not a proper e-mail address!\nThe message can not be send.\nPlease try it again. "; die("status=".urlencode($status)."&sent=0&"); }//End if //Something in the message is required if (empty($message)) { $status = "There is no message!\nYou Cannot send an empty message!"; die("status=".urlencode($status)."&sent=0&"); }//end if /*###########################*/ //Everything looks good.. we are still alive! //Deal with flash carriage return and convert to new lines $message = ereg_replace("\r", "\n", $message); //The subject line $subject = "ourname Email"; //Change this to your information $ourName = "ourname"; $ourEmail = "info@ourname.com"; //Open the template files $toSenderMsg = readTextFile("senderThanks.txt"); //Replace in-built variables in the senderThanks.txt file $toSenderMsg = ereg_replace("\{greetings\}", empty($name) ? "Hello" : "Dear ".$name.",", $toSenderMsg); $toSenderMsg = ereg_replace("\{date\}", date("m/d/Y"), $toSenderMsg); $toSenderMsg = ereg_replace("\{message\}", $message, $toSenderMsg); $ourVersion = readTextFile("websiteMail.txt"); $ourVersion = ereg_replace("\{greetings\}", "Hi,", $ourVersion); $ourVersion = ereg_replace("\{date\}", date("m/d/Y"), $ourVersion); $ourVersion = ereg_replace("\{name\}", empty($name) ? "none" : $name, $ourVersion); $ourVersion = ereg_replace("\{email\}", $email, $ourVersion); $ourVersion = ereg_replace("\{message\}", $message, $ourVersion); //Done with all formatting.. let's send our messages $tTasks = 2; $tDone = 0; //sendMsg function arguments? //sendMsg($to, $toEmail, $subject, $message, $from, $fromEmail) //Send a copy the website user if (sendMsg($name, $email, $subject, $toSenderMsg, $ourName, $ourEmail)) $tDone++; //Send a copy to ourselves if (sendMsg($ourName, $ourEmail, $subject, $ourVersion, empty($name) ? $email : $name, $email)) $tDone++; if ($tDone == $tTasks) { $status = "The message is Sent!\n\nThank you"; print "status=".urlencode($status)."&sent=1&"; return true; } else { $status = "Could not send the message because of an internal server error\nPlease try it again"; die("status=".urlencode($status)."&sent=0&"); }//End if }//End function //Send Flash Email flashEmail($HTTP_POST_VARS); //Goodbye PHP ?> ------------- thanx for any help Quote Link to comment https://forums.phpfreaks.com/topic/89248-flash-php-mail-form-problem/ Share on other sites More sharing options...
Aureole Posted February 3, 2008 Share Posted February 3, 2008 It's probably something to do with register_globals. Quote Link to comment https://forums.phpfreaks.com/topic/89248-flash-php-mail-form-problem/#findComment-456989 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.