Jump to content

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/200031-having-problems-sending-mail-with-mail/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.