seany123 Posted May 19, 2009 Share Posted May 19, 2009 can anyone see anything wrong with this?, its not sending to the email address. <?php $query1 = $db->execute("update `players` set `recover`='$validate' where `email`='$email'"); $subject = "Forgot Password"; $message = "Your Username is $user \n\nYour Recover password link is: http://URL.co.cc/recover.php?recover=$validate \n\nThis is an automatic email so please do not respond \n\nWARNING: DO NOT GIVE OUT THE ADDRESS ABOVE TO ANYONE "; $headers .= "From: forgot@URL.co.cc"; mail("$email", "$subject", "$message", $headers); ?> Quote Link to comment https://forums.phpfreaks.com/topic/158747-solved-using-mail-function/ Share on other sites More sharing options...
Masna Posted May 19, 2009 Share Posted May 19, 2009 Where is $email obtained from? (Also, the quotes used in the first three parameters of mail() are unnecessary.) Quote Link to comment https://forums.phpfreaks.com/topic/158747-solved-using-mail-function/#findComment-837237 Share on other sites More sharing options...
Maq Posted May 19, 2009 Share Posted May 19, 2009 I'm also going to go ahead and assume that you have configured/setup mail? Quote Link to comment https://forums.phpfreaks.com/topic/158747-solved-using-mail-function/#findComment-837239 Share on other sites More sharing options...
seany123 Posted May 19, 2009 Author Share Posted May 19, 2009 can anyone see anything wrong with this?, its not sending to the email address. <?php $query1 = $db->execute("update `players` set `recover`='$validate' where `email`='$email'"); $subject = "Forgot Password"; $message = "Your Username is $user \n\nYour Recover password link is: http://URL.co.cc/recover.php?recover=$validate \n\nThis is an automatic email so please do not respond \n\nWARNING: DO NOT GIVE OUT THE ADDRESS ABOVE TO ANYONE "; $headers .= "From: forgot@URL.co.cc"; mail("$email", "$subject", "$message", $headers); ?> Where is $email obtained from? (Also, the quotes used in the first three parameters of mail() are unnecessary.) Where is $email obtained from? (Also, the quotes used in the first three parameters of mail() are unnecessary.) $email is obtained from the players database. <?php $email = $_POST['email']; $query = $db->execute("select * from `players` where `email`='$email'"); ?> I'm also going to go ahead and assume that you have configured/setup mail? actually i havnt done that yet... i had a look and could only find 1 thing to do with sending mail on my hosts cp... Sendmail path: /usr/sbin/sendmail Quote Link to comment https://forums.phpfreaks.com/topic/158747-solved-using-mail-function/#findComment-837249 Share on other sites More sharing options...
Maq Posted May 19, 2009 Share Posted May 19, 2009 Your hosting provider may already have this setup for you, if not they can take care of it. Quote Link to comment https://forums.phpfreaks.com/topic/158747-solved-using-mail-function/#findComment-837252 Share on other sites More sharing options...
Masna Posted May 19, 2009 Share Posted May 19, 2009 Turn error reporting on. Post here any errors that are printed. error_reporting(E_ALL); //add this to the top of your script Quote Link to comment https://forums.phpfreaks.com/topic/158747-solved-using-mail-function/#findComment-837257 Share on other sites More sharing options...
seany123 Posted May 19, 2009 Author Share Posted May 19, 2009 got a few little warnings but nothing i dont think should stop the mail() errors: Notice: Undefined variable: lang in /home/www/forgot.php on line 10 Notice: Undefined variable: headers in /home/www/forgot.php on line 36 Warning: Cannot modify header information - headers already sent by (output started at /home/www/forgot.php:10) in /home/www/forgot.php on line 38 Notice: Undefined variable: player in /home/www/templates/header.php on line 2 Notice: Undefined variable: error in /home/www/templates/header.php on line 60 Quote Link to comment https://forums.phpfreaks.com/topic/158747-solved-using-mail-function/#findComment-837261 Share on other sites More sharing options...
Masna Posted May 19, 2009 Share Posted May 19, 2009 Add ob_start() to the top of your script. Does mail() work now? Quote Link to comment https://forums.phpfreaks.com/topic/158747-solved-using-mail-function/#findComment-837265 Share on other sites More sharing options...
seany123 Posted May 19, 2009 Author Share Posted May 19, 2009 Add ob_start() to the top of your script. Does mail() work now? no adding ob_start(); didnt change anything. Quote Link to comment https://forums.phpfreaks.com/topic/158747-solved-using-mail-function/#findComment-837272 Share on other sites More sharing options...
Masna Posted May 19, 2009 Share Posted May 19, 2009 Add ob_start() to the top of your script. Does mail() work now? no adding ob_start(); didnt change anything. Underneath the call to mail(), echo $email. What is outputted? Quote Link to comment https://forums.phpfreaks.com/topic/158747-solved-using-mail-function/#findComment-837282 Share on other sites More sharing options...
seany123 Posted May 19, 2009 Author Share Posted May 19, 2009 it echo'd: sean_lincoln@hotmail.com as expected. Quote Link to comment https://forums.phpfreaks.com/topic/158747-solved-using-mail-function/#findComment-837295 Share on other sites More sharing options...
Masna Posted May 19, 2009 Share Posted May 19, 2009 Try getting ridding of the last parameter ($headers). Does it work now? Quote Link to comment https://forums.phpfreaks.com/topic/158747-solved-using-mail-function/#findComment-837301 Share on other sites More sharing options...
seany123 Posted May 19, 2009 Author Share Posted May 19, 2009 Try getting ridding of the last parameter ($headers). Does it work now? YES thankyou, that seems to have fixed the problem.. its emailing instantly now. Quote Link to comment https://forums.phpfreaks.com/topic/158747-solved-using-mail-function/#findComment-837315 Share on other sites More sharing options...
Masna Posted May 19, 2009 Share Posted May 19, 2009 Yeah, it took me a bit longer than it should have to notice it, but your headers are formatted incorrectly. Quote Link to comment https://forums.phpfreaks.com/topic/158747-solved-using-mail-function/#findComment-837317 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.