svgmx5 Posted April 28, 2010 Share Posted April 28, 2010 So, this is a new one for me, i've just started having this problem with the mail() function. For some reason its not sending any emails at all, which is weird since, since it was working before, now it just won't send nothing at all. i don't get any unusual errors, aside from my custom message error. So i'm hopping to post the code i'm using and see if someone can catch what could be the issue. <body> <div id="forgot_pass"> <h1>Password Retrieval</h1> <p>Enter your email to retrieve your password</p> <?php if(isset($_POST['retrieve'])){ $email = $_POST['email']; $new_email = mysql_real_escape_string($email); $check_email = "SELECT * FROM members WHERE memberEmail='$new_email'"; $run = mysql_query($check_email) or die(mysql_error()); $num_rows = mysql_num_rows($run); if($num_rows==0){ $msg = ' <h2>The Email you submited does not exist</h2> '; }else{ $r = mysql_fetch_assoc($run); $dbemail = $r['memberEmail']; $memID = $r['memberID']; if($new_email==$dbemail){ $new_pass = rand(1000,5000); $new_password = md5($new_pass); $to = ''.$email.''; $subject = 'Request for new password'; $from = 'From:[email protected]'; $body=' Your new password has been updated: username: '.$email.' password: '.$new_pass.' '; $send = mail($to, $subject, $body, $from); if($send){ $update = "UPDATE members SET memberPWD='$new_password' WHERE memberID='$memID'"; $run2 = mysql_query($update) or die(mysql_error()); $msg = ' <h2>Your password has been sent to '.$email.'</h2> '; }else{ $msg = ' <h2>There was an internal error send your email</h2> '; } } } } ?> <?php if(isset($msg)){ echo ''.$msg.''; } ?> <form method="post" action="forgot_pass.php"> <p>Email:<br/><input type="text" name="email" /></p> <input type="submit" name="retrieve" value="Send" /> </form> </div> Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/200031-having-problems-sending-mail-with-mail/ Share on other sites More sharing options...
PFMaBiSmAd Posted April 28, 2010 Share Posted April 28, 2010 For debugging purposes, add the following two lines of code after your first opening <?php tag to see if there are any php errors reported - ini_set("display_errors", "1"); error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/200031-having-problems-sending-mail-with-mail/#findComment-1049865 Share on other sites More sharing options...
svgmx5 Posted April 28, 2010 Author Share Posted April 28, 2010 nope nothing came back Quote Link to comment https://forums.phpfreaks.com/topic/200031-having-problems-sending-mail-with-mail/#findComment-1049866 Share on other sites More sharing options...
svgmx5 Posted April 28, 2010 Author Share Posted April 28, 2010 well i figured out the issue, turned out it was with the server... Anyways thanks! Quote Link to comment https://forums.phpfreaks.com/topic/200031-having-problems-sending-mail-with-mail/#findComment-1049867 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.