0
if (mysqli_num_rows($result_verify_email) == 0) { // IF no previous user is   using this email .


        // Create a unique  activation code:
        $activation = md5(uniqid(rand(), true));


        $query_insert_user = "INSERT INTO `members` ( `Username`, `Email`, `Password`, `Activation`) VALUES ( '$name', '$Email', '$Password', '$activation')";


        $result_insert_user = mysqli_query($dbc, $query_insert_user);
        if (!$result_insert_user) {
            echo 'Query Failed ';
        }

        if (mysqli_affected_rows($dbc) == 1) { //If the Insert Query was successfull.


            // Send the email:
            $message = " To activate your account, please click on this link:\n\n";
            $message .= WEBSITE_URL . '/activate.php?email=' . urlencode($Email) . "&key=".$activation;
            mail($Email, 'Registration Confirmation', $message, 'From: ismaakeel@gmail.com');

            // Flush the buffered output.


            // Finish the page:
            echo '<div class="success">Thank you for
registering! A confirmation email
has been sent to '.$Email.' Please click on the Activation Link to Activate     your account </div>';


        } else { // If it did not run OK.
            echo '<div class="errormsgbox">You could not be registered due         to a system
error. We apologize for any
inconvenience.</div>';
        }

    } else { // The email address is not available.
        echo '<div class="errormsgbox" >That email
address has already been registered.
</div>';
    }

This is a sample of my code. I use a simple mail() to send an email, but it is not working. Can anybody point out any mistake? I am not getting error messages, but when I send an email, it is not working. I am not receiving the email! Please help!

1 Answers1

0

First, check where you are hosting the script. Web servers on your PC usually are not configured with a mail server. If you are running the script on a shared hosting service, make sure that the service provides access tot he mail() function, and then contact support of your hosting service.

If you are running your script on a local server, you need to change setting in php.ini to set up your mail function to use SMTP; otherwise, you need to configure a mail server on your PC.

Also, if you use the ini_set() functions in PHP, make sure you are including these functions in the same script as your calls to the mail function, because this value is only set for the duration of the current scripts execution.

Jacob
  • 2,769
  • 3
  • 21
  • 29