nutt318 Posted July 2, 2009 Share Posted July 2, 2009 So I have hosting with godaddy and I updgraded my php4 to php5 due to a joomla extension needing php5. Anyways after upgrading some of my other sites mail() sending is no longer working. It acts like it sends the mail but I never receive the message. I'm guessing some properties changed on how the mail() function works but have been searching forums and google and havent found anything. I have been playing around with it and its something to do with the message part. It not showing the varibles properly and cant find any examples. $msg = "Name: $name \n"; $msg = "E-Mail Address: $email \n"; $msg = " \n"; $msg = "$message \n"; $headers = "From: $name<$email>"; echo' <HTML><HEAD><TITLE>' . $waitmessage . '</TITLE> <META HTTP-EQUIV="refresh" CONTENT="3;url=' . $redirecturl . '">'; mail ($ToEmail, $subject, $msg, $headers); Thanks for the help, if possible can someone provide an example on how to make this work? Quote Link to comment Share on other sites More sharing options...
Adam Posted July 2, 2009 Share Posted July 2, 2009 There have been no changes to the mail function, if there had been they would be listed on the manual. I assume this must be some kind of configuration error... Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted July 2, 2009 Share Posted July 2, 2009 It's not a mail() problem (nothing changed between php4 and php5) and it is not a php5 problem either. Your code was relying on the lazy-way register_globals to "magically" populate program variables from your form data. Register_globals were turned off by default in php4.2 in the year 2002 because they also magically allowed hackers to set session variables by simply putting a same name parameter on the end of the URL. You need to add code to set the variables $name, $email, $message, and any other ones that come from your form, using the correct $_POST['name'], $_POST['email'] ... variables. Quote Link to comment Share on other sites More sharing options...
nutt318 Posted July 2, 2009 Author Share Posted July 2, 2009 Ok, here is the entire code I'm using, I am setting the variables unless this is the wrong way of doing it. <?PHP # Only edit the following lines $redirecturl="http://www.mysite.com"; # Where you're sent after submitting the contact form $subject="mysite - Customer Question"; # Subject of the email message $waitmessage="Please Wait. Sending Information. You will now be redirected back to the homepage."; # Message shown to user while emailing their info $ToEmail="support@mysite.com"; # Enter email address in between $name = $HTTP_POST_VARS['userName']; $email = $HTTP_POST_VARS['userEmail']; # $phone = $HTTP_POST_VARS['userPhone']; # $subject2 = $HTTP_POST_VARS['userSubject']; $message = $HTTP_POST_VARS['userMessage']; # if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) { # echo "<h4>Invalid Email Address</h4>"; # echo "<a href='javascript:history.back(1);'>Back</a>"; $msg = "Name: $name \n"; $msg = "E-Mail Address: $email \n"; $msg = " \n"; $msg = "$message \n"; $headers = "From: $name<$email>"; echo' <HTML><HEAD><TITLE>' . $waitmessage . '</TITLE> <META HTTP-EQUIV="refresh" CONTENT="3;url=' . $redirecturl . '">'; mail ($ToEmail, $subject, $msg, $headers); echo ' <CENTER>' . $waitmessage . ' <P> </P> '; ?> Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted July 2, 2009 Share Posted July 2, 2009 $HTTP_POST_VARS were depreciated even longer ago in php4.1, they are turned off by default in php5, and completely removed in php6. Use $_POST Quote Link to comment Share on other sites More sharing options...
nutt318 Posted July 2, 2009 Author Share Posted July 2, 2009 PFMaBiSmAd, Thanks for the help, that worked. Quote Link to comment Share on other sites More sharing options...
nutt318 Posted July 2, 2009 Author Share Posted July 2, 2009 where is the solved button? Quote Link to comment Share on other sites More sharing options...
nutt318 Posted July 2, 2009 Author Share Posted July 2, 2009 nevermind, someone else got it I guess Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted July 2, 2009 Share Posted July 2, 2009 Got it for you.. Quote Link to comment Share on other sites More sharing options...
totallytotallyamazing Posted March 11, 2014 Share Posted March 11, 2014 Thank you PFMaBiSmAd and nutt318! This post helped me out! Below is my code with the form vars declared as php vars: <?phpif(isset($_POST['email'])) {// EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "totallytotallyamazing@gmail.com"; $email_subject = "TTA FILL-IN FORM"; // DECLARE FORM VARS AS PHP VARS $name = $_POST['name']; $email = $_POST['email']; $url = $_POST['url']; $comment = $_POST['comment']; $email_message .= "Name: ".($name)."\n"; $email_message .= "Email: ".($email)."\n"; $email_message .= "URL: ".($url)."\n"; $email_message .= "Comments: ".($comment)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); }?> Quote Link to comment 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.