propel Posted August 22, 2007 Share Posted August 22, 2007 First off, hello everyone. This is my first post to this forum. The problem that I am having is that I have a page that uses the mail() function. The page is on admin panel of a store and is called from another page that lists all of the orders. Basically, the script updates the status of the order to indicate that the payment has been received and sends an email to the customer to notify them of the payment receipt. The script was working fine for months, but recently stopped working completely. (Although no error is thrown.) The only thing that I can think that could have affected this is that the host recently upgraded from PHP 4 to PHP 5; however, I have another site on the same account where the mail function works just fine. Any ideas? Here's the code: include "../globalvariables.php"; //just some global variables like the HTML for the header and footer of the email $orderid = $_GET[iD]; //order ID passed in the URL $customer = $_GET[C]; //customer ID passed in the URL //update order (marks order as "payment received" $query = "UPDATE orders SET status='2' WHERE ID='$orderid'"; $result = mysql_query($query) or die ("DB-fout:".mysql_error()); //mail customer $querymail = "SELECT fname, lname, email FROM customers WHERE ID = $customer"; $resultmail = mysql_query($querymail) or die ("DB-fout:".mysql_error()); $rowm = mysql_fetch_array($resultmail); $customermail = $mailheader; $customermail .= "Dear $rowm[fname] $rowm[lname],<br><br>"; $customermail .= "We have received the payment for your OrderID $orderid. Your package will be shipped as soon as possible.<br>"; $customermail .= $mailfooter; $to = "$rowm[email]"; $subject = "Payment received for Order $orderid"; $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\n"; $headers .= $headersfrom; mail($to, $subject, $customermail, $headers); header("Location: packages.php"); Thanks!!! Chris Quote Link to comment Share on other sites More sharing options...
propel Posted August 23, 2007 Author Share Posted August 23, 2007 Bump. Please help if you can. I'm stumped. ??? Thanks again!!! Quote Link to comment Share on other sites More sharing options...
Jessica Posted August 23, 2007 Share Posted August 23, 2007 $headers .= "Content-type: text/html; charset=iso-8859-1\n"; $headers .= $headersfrom; mail($to, $subject, $customermail, $headers); Where does $headersfrom come to? Try changing mail to this to the top of every page: ini_set('display_errors', 1); error_reporting(E_ALL); Then change the mail() line to: if(mail($to, $subject, $customermail, $headers)){ headers('Location: packages.php'); }else{ print "$to - $subject - $customeremail - $headers"; die(); } Your page might not redirect to packages.php but you will be able to debug. Quote Link to comment Share on other sites More sharing options...
propel Posted August 23, 2007 Author Share Posted August 23, 2007 I tired doing something similar already to print out each of the variables that are passed to the mail function and they all appeared valid. Thanks for the suggestion jesirose. I'll keep plugging away at it... Quote Link to comment Share on other sites More sharing options...
Jessica Posted August 23, 2007 Share Posted August 23, 2007 Did you add the error_reporting code? You should see errors if you're not getting the mail. Also, have you looked at the mail() function's other arguments? I have to use '-f-me@mail.com' in order to avoid spam filtering on the outgoing server. Quote Link to comment Share on other sites More sharing options...
propel Posted August 23, 2007 Author Share Posted August 23, 2007 yeah, just tried that. unforuntately, same results. Quote Link to comment Share on other sites More sharing options...
trq Posted August 23, 2007 Share Posted August 23, 2007 Can you at least post your current code, including all suggested debugging changes. Quote Link to comment Share on other sites More sharing options...
propel Posted August 23, 2007 Author Share Posted August 23, 2007 Nevermind. Finally got a reply from my host. They transferred all the files to a new server and, in the process, changed all of the permissions. I just chmod'ed it back to 755 and it works fine now. Thanks again for your help everyone!!! 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.