I know that this is somewhere else on the site, but for some reason the answers that I found here have still not helped, I still canβt get it to work after trying different things all day. My goal was for the verification code to be sent in an email that the user enters. I know only a small amount of PHP and followed the tutorial for the registration / registration system, but I'm sure php is working fine and the problem is in my sendmail.ini and php.ini. Here is my sendmail.ini
And my parts that I edited on my php.ini
extension=php_openssl.dll [mail function] ; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury SMTP =smtp.gmail.com smtp_port =587 ; For Win32 only. ; http://php.net/sendmail-from sendmail_from = myemail@gmail.com sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t" ;sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe" ; Force the addition of the specified parameters to be passed as extra parameters ; to the sendmail binary. These parameters will always replace the value of ; the 5th parameter to mail(), even in safe mode. ;mail.force_extra_parameters =
and my php code if necessary
<?php session_start(); include('configdb.php'); if(isset($_POST['submit'])) { //whether the username is blank if($_POST['username'] == '') { $_SESSION['error']['username'] = "User Name is required."; } //whether the email is blank if($_POST['email'] == '') { $_SESSION['error']['email'] = "E-mail is required."; } else { //whether the email format is correct if(preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9._-]+)+$/", $_POST['email'])) { //if it has the correct format whether the email has already exist $email= $_POST['email']; $sql1 = "SELECT * FROM user WHERE email = '$email'"; $result1 = mysqli_query($mysqli,$sql1) or die(mysqli_error()); if (mysqli_num_rows($result1) > 0) { $_SESSION['error']['email'] = "This Email is already used."; } } else { //this error will set if the email format is not correct $_SESSION['error']['email'] = "Your email is not valid."; } } //whether the password is blank if($_POST['password'] == '') { $_SESSION['error']['password'] = "Password is required."; } //if the error exist, we will go to registration form if(isset($_SESSION['error'])) { header("Location: index.php"); exit; } else { $username = $_POST['username']; $email = $_POST['email']; $password = $_POST['password']; $com_code = md5(uniqid(rand())); $sql2 = "INSERT INTO user (username, email, password, com_code) VALUES ('$username', '$email', '$password', '$com_code')"; $result2 = mysqli_query($mysqli,$sql2) or die(mysqli_error()); if($result2) { $to = $email; $subject = "Confirmation for $username"; $header = "Confirmation from"; $message = "Please click the link below to verify and activate your account. rn"; $message .= "http://www.yourname.com/confirm.php?passkey=$com_code"; $sentmail = mail($to,$subject,$message,$header); if($sentmail) { echo "Your confirmation link has been sent to your e-mail address."; } else { echo "Error while sending confirmation link to your e-mail address"; } } } } ?>
As I said, I have been working on this for some time, and I cannot understand that this is really so, but since I am still participating, I have not seen this. Thanks for the help!
source share