Jacbey Posted June 11, 2011 Share Posted June 11, 2011 Hi Guys, I'm having an annoying problem with sending this email. It keeps sending me the error but I fail to see the actual error in the code. Please help? $mailquery = "SELECT username, first_name, last_name, password, email, dob, mob, yob, year, gender FROM spotty WHERE user_id = '" . $id_receiver . "'"; $mailresult = mysql_query($mailquery) or die('Error Getting user_id'); $mailrow = mysql_fetch_array($mailresult); //start message email send $email = $mailquery['email']; echo $email; $to = $email; //$from = "iWatch" ; $subject = $subject . " - iWatch"; $from = "iWatch"; $msgsub = $subject; $headers = "From: " . $from . "\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; $message = " <html> <body bgcolor='#DCEEFC'> <center> <b>Hi " . $to . ",</b> <br /> <font color='red'>" . $sender . " sent you a message.<br /></font> <br /> <table> <tr> <td>From: </td> <td>" . $sender ."</a></font></td> </tr> <tr> <td>Subject: </td> <td>" . $msgsub . "</td> </tr> <tr> <td>Message: </td> <td>" . $body . "</td> </tr> </table> </center> <br /><br /> Regards; maker and founder of iWatch; Jacob Porter. </body> </html> "; $body = $message; if(mail($to, $subject, $body, $headers)) { echo "Email sent to " . $friendusername . "!"; } else { echo("<p>Message delivery failed...</p>"); } if($quer){ echo "<meta http-equiv='refresh' content='4;url=http://www.klueless.net/daisysite/profile.php?id=" . $id_receiver . "&sent=1'>";} else {echo "<meta http-equiv='refresh' content='4;url=http://www.klueless.net/daisysite/profile.php?id=" . $id_receiver . "&sent=2'>";} } } Thanks in advance, Jacob Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted June 11, 2011 Share Posted June 11, 2011 And what error would that be? Quote Link to comment Share on other sites More sharing options...
Jacbey Posted June 11, 2011 Author Share Posted June 11, 2011 Whoops, sorry. It gives me the Mail cannot send error I put at the bottom. [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
fugix Posted June 11, 2011 Share Posted June 11, 2011 any parse errors? also, you have your $from variable commented out Quote Link to comment Share on other sites More sharing options...
Jacbey Posted June 11, 2011 Author Share Posted June 11, 2011 Nope, no parse errors. Also that is a dupe and I don't like deleting things so I comment them out. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted June 11, 2011 Share Posted June 11, 2011 Do you have error_reporting = -1 and display_errors = On in your php.ini file? You should always have those set to show you errors while developing (but not on live server). In this case, add these lines to the beginning of the script and post any additional errors that are returned. ini_set ("display_errors", "On"); error_reporting(-1); Quote Link to comment Share on other sites More sharing options...
Jacbey Posted June 11, 2011 Author Share Posted June 11, 2011 Do you have error_reporting = -1 and display_errors = On in your php.ini file? You should always have those set to show you errors while developing (but not on live server). In this case, add these lines to the beginning of the script and post any additional errors that are returned. ini_set ("display_errors", "On"); error_reporting(-1); yeah I do. but it hasn't shown any errors. Quote Link to comment Share on other sites More sharing options...
fugix Posted June 11, 2011 Share Posted June 11, 2011 are you on a valid SMTP server? Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted June 11, 2011 Share Posted June 11, 2011 Should have maybe asked this first, but you do have a mail server set up on the web server you're using, right? Have you successfully sent mail from it previously? Temporarily change the error message to echo the parameters that were sent to mail(). That output might provide enough information to figure out what's up with it. if(mail($to, $subject, $body, $headers)) { echo "Email sent to " . $friendusername . "!"; } else { echo("<p>Message delivery failed...</p><br>Mail parameters:<br><pre>To: $to<br>Subject: $subject<br>Body: $body<br>Headers: $headers</pre>"); } Quote Link to comment Share on other sites More sharing options...
Jacbey Posted June 11, 2011 Author Share Posted June 11, 2011 Yes I have sent from it before. And ok. Quote Link to comment Share on other sites More sharing options...
Jacbey Posted June 11, 2011 Author Share Posted June 11, 2011 This is what I got. I think it's the email address? [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
fugix Posted June 11, 2011 Share Posted June 11, 2011 change $email = $mailquery['email']; to $email = $mailrow['email']; simple variable misplacement 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.