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: [email protected]"; mail("$email", "$subject", "$message", $headers); ?> 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.) 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? 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: [email protected]"; 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 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. 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 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 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? 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. 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? 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: [email protected] as expected. 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? 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. 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. Link to comment https://forums.phpfreaks.com/topic/158747-solved-using-mail-function/#findComment-837317 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.