Search the Community
Showing results for tags 'mail function'.
-
<form action="forgotPsw.php" method="post"> Enter you Email Address: <input type="text" name="email"> <input type="submit" name="submit" value="Send"> </form> With this code am trying to send an email using mail function, which is not doing that and with no errors displaying, so i cant really figure out what is the problem since its updating the database giving the write echo statements but the email is not going through? please assist me <?php error_reporting(0); $email=$_POST['email']; if($_POST['submit']=='Send') { require_once "my database"; mysql_connect($svr, $dba, $pwd) or die(mysql_error); mysql_select_db($dbt); $query="select * from users where Email='$email'"; $result=mysql_query($query) or die(error); // checks if the username is in use if(mysql_num_rows($result)){ echo "User exist ----"; }else{ echo "No user exist with this email address----"; } if(mysql_num_rows($result)){ //$code=rand(100,999); //$message="You activation link is: http://10.10.200.250/cmsintranet/forgotPsw.php?email=$email&code=$code"; //mail($email, "Activation link", $message); //send email $mail->Mailer = "smtp"; $mail->Host = "my host"; $mail->Port = 25; $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = "i used an email address"; // SMTP username $mail->Password = "psw to the email"; // SMTP password //create a new random password $password = substr(md5(uniqid(rand(),1)),3,10); $pass = md5($password); //encrypted version for database entry $to = "$email"; $subject = "Account Details Recovery"; $body = "Hi $r->username, nn you or someone else have requested your account details. nn Here is your account information please keep this as you may need this at a later stage. nnYour username is $r->username nn your password is $password nn Your password has been reset please login and change your password to something more rememberable.nn Regards Site Admin"; $additionalheaders = "From: <email.......>rn"; mail($to, $subject, $body, $additionalheaders); //update database $sql = mysql_query("UPDATE users SET u_password='$pass' WHERE Email = '$email'")or die (mysql_error()); $rsent = true; //show any errors if (!empty($error)){ $i = 0; while ($i < count($error)){ //echo "<div class="msg-error">".$error[$i]."</div>"; $i ++; } } if ($rsent == true){ echo "<p>You have been sent an email with your account details to $email</p>"; } else { echo "<p>Please enter your e-mail address. You will receive a new password via e-mail.</p>"; } //echo "Email sent"; }else{ echo "Email not sent"; } } ?>